wordpress怎么调用特定文章列表

更新于 2022年1月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; ?>

你可能还喜欢下面这些文章

蜂集采集器jQuery选择器采集教程蜂集采集器jQuery选择器采集教程

//www.imwpweb.com”>imwpweb</a></div></div></body></html>使用id选择器。

wordpress如何在一个页面显示所有文章wordpress如何在一个页面显示所有文章

让WordPress一个页面显示全部分类的文章cat=’ . $cat->php echo $cat->a href=”<$cats = get_categories(array(‘include’ =>

WordPress怎么增加文章排序方式WordPress怎么增加文章排序方式

WordPress怎么增加文章排序方式?实现过程也比较简单,一个是构造链接,另外一个是使用query_posts来改变一下主循环就可以了。 $orderby, ‘order’ =>

蜂集采集器如何采集标签蜂集采集器如何采集标签

//www.imwpweb.com”>标签二</a>。//www.imwpweb.com”>标签三</a></div>tag是在a标签中,那么jquery选择器可以写成。

wordpress怎么实现文章分页wordpress怎么实现文章分页

最近发现 有不少文章配上图片,写得比较长。’wp_more’,<if ( strpos( $content,'<if ( strpos( $content, ‘<

Wordpress 主循环 - 如何在指定文章数之前添加classWordPress 主循环 – 如何在指定文章数之前添加class

有没有办法在 WordPress 循环代码中获取多个项目: if ($count<a href=”https://stackoverflow.com/questions/19303556/wordpress-loop-how-to-co

wprec推荐插件模板变量文档以及样式推荐wprec推荐插件模板变量文档以及样式推荐

wpac是一款wordpress自动配图插件,可以丰富文章内容,对提升排名有很大帮助。p style=”font-size:18px;”>你可能还喜欢下面这些文章<p>{excerpt}<

wordpress怎么获取某个栏目链接地址wordpress怎么获取某个栏目链接地址

” title=”Category Name”>$cat_links=get_category_link($cat->php echo $cat->