WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


share|improve this answer

Your Answer


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.