首先,你需要了解query_posts函数。该函数的作用就是对文章进行检索、挑选、排序,在其后的loop循环中使用经过挑选、排序的文章。例如:
复制代码 代码如下:';the_title();echo '';endwhile;wp_reset_query();将随机列出一条文章的标题。至于query_posts的具体参数,请参考开发手册。
接下来,我们就是要通过对query_posts的参数进行调整,挑选出置顶的文章列表了。
复制代码
代码如下:$query_post = array('posts_per_page' => 10,'post__in' => get_option('sticky_posts'),'caller_get_posts' => 1);query_posts($query_post);?>
参数用一个数组的形式放在$query_post中,关键的参数为'post__in' =>get_option('sticky_posts')和'caller_get_posts' => 0。














发表评论