0

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?

2

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

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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