Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi i am new in wordpress and want to know about query_posts() function. If there is index page or home page than there is no need this function to display post but if i made custom page than there this function must used to display. Why?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

See When should you use WP_Query vs query_posts() vs get_posts()?

For a custom post type or a simple page you don’t need query_posts(). Usually, you almost never need it, because it will replace the default query which leads to some counter-intuitive side effects.

When in doubt use get_posts().

share|improve this answer
    
Thank you.I am using now WP_query(). –  brbaral Feb 15 '12 at 7:52
add comment

i agree w/ get_posts() for a secondary loop. if you need to modify the query on one of your templates i'd suggest using pre_get_posts()

http://codex.wordpress.org/Custom_Queries

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.