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