欢迎来到资源库(www.zyku.net)

WordPress

当前位置:首页 > CMS教程 > WordPress > 特定文章

wordpress特定文章列表调用的方法

时间:2017-03-04|栏目:WordPress|点击:|我要投稿

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.zyku.net)

上一篇:wordpress替换更改登录页面logo与链接的方法

栏    目:WordPress

下一篇:wordpress中的Pingback和Trackback到底有何区别

本文标题:wordpress特定文章列表调用的方法

本文地址:https://www.zyku.net/wp/1084.html

关于我们 | 版权申明 | 寻求合作 |

重要申明:本站所有的文章、图片、评论等内容,均由网友发表或上传并维护或收集自网络,仅供个人学习交流使用,版权归原作者所有。

如有侵犯您的版权,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:95148658 | 邮箱:mb8#qq.com(#换成@)

苏ICP备2020066115号-1

本网站由提供CDN加速/云存储服务