在我的博客上http://flattrendz.com/, 我当前想显示最新的粘贴帖子。
我使用的代码是http://justintadlock.com/archives/2009/03/28/get-the-latest-sticky-posts-in-wordpress
<?php
/* 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, \'caller_get_posts\' => 1 ) );
?>
<!-- BLOG BAR -->
<div class="blog_bar <?php echo $blog_bar_class; ?>">
<div class="container">
<div class="text-center">
<h2 class="lead">
<span><?php printf(__(\'From Our Blog\', \'dot\')); ?> </span>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__(\'%s\', \'dot\'), get_the_title()); ?>"><?php the_title(); ?> <i class="icon-long-arrow-right"></i></a>
</h2>
</div>
</div>
</div>
<!-- // BLOG BAR -->
<?php endwhile;?>
<?php
}
else { }
/* Restore original Post Data */
wp_reset_query();
?>
我需要做的是,如果有贴子标记为粘滞贴子,那么只显示最新的粘滞贴子,或者只显示最新的贴子。