有的时刻我们会在特别位置显现一些网站的置顶文章,那末我们须要怎样操纵呢?
起首设置几篇文章为置顶文章,这里要申明的是,设置置顶文章不须要在文章编辑页面,而是文章的疾速编辑里有置顶按钮
然后,在须要显现置顶文章的处所,插进去下面的代码,即可挪用wordpress猎取指定文章的要领
<ul>
<?php $sticky = get_option('sticky_posts'); rsort( $sticky );
$sticky = array_slice( $sticky, 0, 2);query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
if (have_posts()) :while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>

评论列表