手机
当前位置:查字典教程网 >CMS教程 >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; ?>

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

【wordpress调用特定文章列表的技巧分享】相关文章:

wordpress恶意代码解决方法分享

为wordpress绑定多个域名的方法分享

为WordPress添加文章字数统计的方法

Wordpress 的用户管理教程

Wordpress自定义函数控制文章标题长度

WordPress查询某年某月文章的SQL语句

wordpress 优化指南

wordpress首页文章限制显示字数的方法

wordpress自定义摘要截取字数的代码

Wordpress不用插件的SEO优化方法分享

精品推荐
分类导航