WordPress Theme Maker Tutorial 5: Looping

Source: Internet
Author: User

Call all pages, Post_type values: page corresponding pages, post corresponding article

<?PHP$args=Array(  ' Post_type ' = ' page ' );$the _query=NewWp_query ($args );//The Loopif($the _query-have_posts ()) {    Echo' <ul> ';  while($the _query-have_posts ()) {        $the _query-The_post (); Echo' <li> '. Get_the_title (). ' </li> '; }    Echo' </ul> ';} Else {    //no posts found}/*Restore original Post Data*/Wp_reset_postdata ();?>

To invoke the multi-ID content, modify the parameter to:

$args=array(' post_type ' = ' page ',' page_id=2,86 ');

Invokes the specified ID content and modifies the parameter to:

$args=array' post_type ' = ' page ',' page_id ' =>2);

To know how to invoke other content within a loop, see:

WordPress Theme Creation Tutorial 6: Common Template Tags

View Wp_query documentation for WordPress

WordPress Theme Maker Tutorial 5: Looping

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.