Wp-query ways to invoke previous articles

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.