Home  >  Article  >  CMS Tutorial  >  How to call a specific article list in wordpress

How to call a specific article list in wordpress

藏色散人
藏色散人Original
2019-12-28 09:48:233447browse

How to call a specific article list in wordpress

#How to call a specific article list in wordpress?

In WordPress theme production and development, it is often necessary to call a specified article or article list on a specific page. Next, I will teach you how to call a WordPress article list.

Recommended: "wordpress tutorial"

Call the latest article on the website:

The code is as follows:

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

Calling random articles:

The code is as follows:

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

Calling the latest articles under a certain category:

The code is as follows:

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

Exclude a certain category The following articles:

The code is as follows:

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

The above is the calling method of the article list. You can combine the codes in the example to achieve the effect you need.

The above is the detailed content of How to call a specific article list in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn