---restore content starts---
Using the powerful Wp-query function to invoke the previous articles under the specified classification, the following code indicates that the first two articles under the classification ID4 are called.
<?php$cunt_wenzhen = Array (' Cat ' = ' 4 ',//Call the Category 4, you can modify the category id ' posts_per_page ' = ' 2 ',//display the first two articles, can be modified to show the number of articles); $the _ query = new Wp_query ($cunt _wenzhen); Start loop if ($the _query->have_posts ()) {//If the result is found, output the following echo ' <ul> '; while ($the _query->have_posts ()) {//again determine if there is a result $the _query->the_post ();//Do not ask why, every time to write this; ?> <li><a href= "<?php the_permalink ();? > "><?php the_title ();? ></a></li> <?php } echo ' </ul> ';} else { //If no result is found, output this} wp_reset_ PostData ();//Don't ask why, always remember to write it well?>
---restore content ends---
Wp-query ways to invoke previous articles