我想通过修改主循环来显示最近发布的两篇粘性帖子。以下循环的简单事件。
然而,如果我计划在将来发布一篇粘性文章,循环就会失败——只显示一篇粘性文章。这就好像它可以看到有一个新的粘性帖子,但由于它被安排好了,所以不会显示出来。然后循环认为它已经显示了我请求的两篇帖子。有什么想法吗?
/* Get all sticky posts */
$sticky = get_option( \'sticky_posts\' );
/* Sort the stickies with the newest ones at the top */
rsort( $sticky );
/* Get the 2 newest stickies (change 2 for a different number) */
$sticky = array_slice( $sticky, 0, 2 );
/* Query sticky posts */
query_posts( array( \'post__in\' => $sticky, \'ignore_sticky_posts\' => 1 ) );
while (have_posts()) : the_post();
the_title();
the_excerpt();
endwhile();
/* Continue with Page Template */