wordpress怎么调用特定文章列表

路丁网 2020年1月18日08:45:48WordPress评论43字数 981阅读3分16秒阅读模式

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; ?>

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

  • 本文由 发表于 2020年1月18日08:45:48
2020创业好项目排行榜(农村创业50个项目) WordPress

2020创业好项目排行榜(农村创业50个项目)

[ 路丁前言 ] 自主创业好的投资项目有很多,说到冷门暴利制造行业,禁不住令人想起成本低高收益,坐享井喷式机遇,有一大把的银两赚……那麼,你了解2019年冷门暴利的小本创业项目有什么吗?接下去,十叁就...
WordPress配置Memcached缓存教程(无需代码) WordPress

WordPress配置Memcached缓存教程(无需代码)

很多人都知道WordPress可以通过缓存来提高网站加载速度,其实除了WordPress本身可以缓存外,我们还可以在服务器上来使用对象缓存来加速网站,在本文中我们为大家带来WordPress配置Mem...
WordPress更换主题,你需要注意哪些事情 WordPress

WordPress更换主题,你需要注意哪些事情

在WordPress中,虽然更换主题这个功能是一件非常简单的事情,只需要点几个下就能切换,不过对于我们的WordPress站点来说,却并不是一件小事,因为许多东西包括外观、功能、使用方法等都有可能发生...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定