首页  >  文章  >  CMS教程  >  wordpress怎么调用特定文章列表

wordpress怎么调用特定文章列表

藏色散人
藏色散人原创
2019-12-28 09:48:233447浏览

wordpress怎么调用特定文章列表

wordpress怎么调用特定文章列表?

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

  推荐:《wordpress教程

调用网站最新文章:

代码如下:

<?php
query_posts(&#39;showposts=10&orderby=new&#39;); 
//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(&#39;showposts=10&orderby=rand&#39;); 
//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(&#39;showposts=10&cat=1&#39;); 
//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(&#39;showposts=10&cat=-1&#39;); 
//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; 
?>

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

以上是wordpress怎么调用特定文章列表的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn