WordPress Call Specific List of Articles Skills Sharing

Posted on

Call the latest article on the website:

Copy code

The code is as follows:

<?php
Query_posts (‘show Posts = 10 & order by = new’); //show Posts = 10 means 10 articles
while(have_posts()): the_post();
?>
<li> <a href=”<?Php the_permalink();?>”target=”_blank”><?Php the_title()></a></li>//Here you can write your own style.
<?php endwhile; ?>

Call random articles:

Copy code

The code is as follows:

<?php
Query_posts (‘show Posts = 10 & order by = rand’); //show Posts = 10 means 10 articles
while(have_posts()): the_post();
?>
<li> <a href=”<?Php the_permalink();?>”target=”_blank”><?Php the_title()></a></li>//Here you can write your own style.
<?php endwhile; ?>

Call the latest article under a category:

Copy code

The code is as follows:

<?php
Query_posts (‘show Posts = 10 & Cat = 1’); //cat = 1 is the classification below for calling 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 articles under a category:

Copy code

The code is as follows:

<?php
Query_posts (‘showposts = 10 & cat= – 1’); //cat= – 1 is the category below excluding 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 invocation method of the article list, which can combine the code in the example to achieve the desired effect.

Leave a Reply

Your email address will not be published.