wordpress获取置顶文章列表的方法


当前第2页 返回上一页


代码如下:

$query_post = array(
'posts_per_page' => 10,
'post__in' => get_option('sticky_posts'),
'caller_get_posts' => 1
);
query_posts($query_post);
?>
<ul style="display:none;">
<?php while(have_posts()):the_post(); ?>
<li><a title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
wp_reset_query();

参数用一个数组的形式放在$query_post中,关键的参数为'post__in' =>get_option('sticky_posts')和'caller_get_posts' => 0。

'post__in' => get_option('sticky_posts')确定了该LOOP调用的是置顶文章列表。'caller_get_posts'的作用是排除非指定性文章,即除了置顶文章之外,不显示其他的文章。(不添加的情况下,如果置顶文章条目不足'posts_per_page'规定的值,会用最新文章替补完整。)


标签:WordPress

返回前面的内容

相关阅读 >>

wordpress 让 php 更流行了 而不是框架

php多用户博客系统分析[想做多用户博客的朋友,需要了解]

wordpress wp_head()函数使页面顶部总空白28px

phpstudy 2016 使用教程详解(支持php7)

文档格式转换大全:怎么把word文档转成pdf,wps文档转换成word

wordpres对前端页面调试时的两个php函数使用小技巧

wordpress博客添加mp3播放器

博客建设需要做些什么?

wordpress上一页下一页无插件分页函数实例

利用fix rss feeds插件修复wordpress的feed显示错误

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...