首页 > CMS教程 > WordPress    日期:2020-03-25 / 来自互联网 / 浏览

调用网站最新文章:

<?php
query_posts('showposts=10&orderby=new'); //showposts=10表示10篇
while(have_posts()): the_post();
?>
//这里可以写成你自己需要的样式
<li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title();?> <?php the_time('Y-m-d'); ?></a></li>
<?php endwhile; ?>

调用随机文章:

query_posts('showposts=10&orderby=rand');

调用某个分类下的最新文章:

query_posts('showposts=10&cat=1'); //cat=1为调用ID为1的分类下文章

排除某个分类下的文章:

query_posts('showposts=10&cat=-1'); //cat=-1为排除ID为1的分类下文章

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章