wordpress特定位置调用置顶(sticky)的文章列表
获取wordpress置顶文章 方法如下:
<ul id="sul">
<?php
$sticky = get_option('sticky_posts');
rsort( $sticky );//对数组逆向排序,即大ID在前
$sticky = array_slice( $sticky, 0, 10);//输出置顶文章数,请修改10,0不要动,如果需要全部置顶文章输出,可以把这句注释掉
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
if (have_posts()) :while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>" ><img src="<?php echo catch_that_image() ?>" alt="" /></a><span><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></span></li>
<?php endwhile; endif; ?>
</ul>
注:红色的部分是调用的博客文章里面的图片,如果没有图片则会显示一个系统默认的图片。
博客文章的图片的调用方法请看:wordpress调用文章的图片的方法。