欢迎来到抓润网

wordpress特定文章列表调用的方法_WordPress教程_抓润网

来源: 互联网 日期: 2020-07-16 17:07:44

wordpress主题制作开发中经常会需要在特定的页面中调用出指定的文章或文章列表,接下来就来教大家如何调用出wordpress文章列表。

调用网站最新文章:

<?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() ?></a></li> //这里可以写成你自己需要的样式
<?php endwhile; ?>

调用随机文章:

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

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

<?php 
query_posts('showposts=10&cat=1'); //cat=1为调用ID为1的分类下文章
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  <?php endwhile; ?>

排除某个分类下的文章:

<?php 
query_posts('showposts=10&cat=-1'); //cat=-1为排除ID为1的分类下文章
while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  <?php endwhile; ?>

以上就是文章列表的调用方法,可以将例子中的代码结合起来达到你需要的效果。

(抓润网帝国模板 www.zhuarun.com)


上一篇:wordpress中的Pingback和Trackback到底有何区别_WordPress教程_抓润网

下一篇:wordpress替换更改登录页面logo与链接的方法_WordPress教程_抓润网

  • 在线客服

    点击这里给我发消息 点击这里给我发消息

    官方微信

    仅处理投诉、举报及平台使用问题;
    商品问题请咨询商家客服!

浏览记录