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

How to call a specific article list in wordpress

藏色散人
Release: 2022-04-15 16:49:22
Original
3541 people have browsed it

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; ?>
Copy after login

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; 
?>
Copy after login

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; 
?>
Copy after login

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; 
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template