#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('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; ?>
Calling random articles:
The code is as follows:
<?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; ?>
Calling the latest articles under a certain category:
The code is as follows:
<?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; ?>
Exclude a certain category The following articles:
The code is as follows:
<?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; ?>
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!