像这样的方法应该会奏效:
$sticky = get_option( \'sticky_posts\' );
if ( !empty( $sticky ) ) { // don\'t show anything if there are no sticky posts
$args = array(
\'posts_per_page\' => -1, // show all sticky posts
\'post__in\' => $sticky,
\'ignore_sticky_posts\' => 1
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
$query->the_post();
// display your sticky post here (however you like to do it)
}
}
你应该把这个放在你的
front-page.php
文件它将选择所有粘性帖子并显示它们。