WordPress custom query query_posts

Source: Internet
Author: User

Reprinted from: http://blog.sina.com.cn/s/blog_a225d3970101331q.html

The query_posts function is only used to modify the Home Page loop, rather than generating a secondary loop on the page. If you want to generate another loop outside the main loop, you should create an independent wp_query object and use these objects to generate a loop. Using query_posts in a loop outside the main loop will lead to deviation of the main loop operation, and the page may display the content you do not want to see.

The query_posts function will rewrite and replace the primary query on the page. To be cautious, do not use query_posts for other purposes.

 

(From WordPress gdt topic)

 


 $ Prologue_query = New Wp_query ('showposts = '. $ Num_posts . '& Post_status = publish & tag _ not_in = 44' );  Ob_start  ();  While ($ Prologue_query -> Have_posts ()): $ Prologue_query -> The_post ();  $ Current_user_id = Get_the_author_id ();  $ Postdate = Get_gmt_from_date (get_the_time ('Y-m-d h: I: s' ));  If ( $ Postdate <= $ Load_time ) Continue  ; //  If (get_the_time ('Y-m-d h: I: s') <= $ load_time) continue;          $ Number_of_new_posts ++ ;  If ( $ Frontpage  ){ ?> <? PHP}  Endwhile ;

 

 

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.