本文整理自网络,侵删。
首先,你需要了解query_posts函数。该函数的作用就是对文章进行检索、挑选、排序,在其后的LOOP循环中使用经过挑选、排序的文章。例如:
代码如下:
<?php
query_posts('posts_per_page=10&ignore_sticky_posts=1&orderby=rand');
while(have_posts()):the_post();
echo '<li>';the_title();echo '</li>';
endwhile;
wp_reset_query();
<?php
query_posts('posts_per_page=10&ignore_sticky_posts=1&orderby=rand');
while(have_posts()):the_post();
echo '<li>';the_title();echo '</li>';
endwhile;
wp_reset_query();
将随机列出一条文章的标题。至于query_posts的具体参数,请参考开发手册。
接下来,我们就是要通过对query_posts的参数进行调整,挑选出置顶的文章列表了。
相关阅读 >>
利用fix rss feeds插件修复wordpress的feed显示错误
主机nginx + docker wordpress mysql搭建的详细步骤
对帝国cms、dedecms、phpcms、discuz、phpwind、xiuno负载测试总结
crayon syntax highlighter 强大的wp代码高亮插件安装方法
wordpress特定文章对搜索引擎隐藏或只允许搜索引擎查看
详解wordpress开发中get_header()获取头部函数的用法
更多相关阅读请进入《wordpress》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。