query_posts codex correct or not?
-
During the course of my delving into WordPress and getting to know it fairly intimately I”ve become confused about the loop due to conflicting information around the web and possibly in the codex section on query_posts.
The codex statesThe query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loops on the page. If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use those instead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying things that you were not expecting.
The query_posts function overrides and replaces the main query for the page. To save your sanity, do not use it for any other purpose.
Now I’ve visited many sites and purchased a book or two about WordPress and they all use the query_posts as a means for creating multiple loops on a page. One book recently released by two very prominent WordPress aficionados/gurus, uses examples of query_posts as a significant way to include multiple loops on a page. If someone could please shed some light on this I’d appreciate it. I have been relying very heavily on the codex for reference and example but if it’s not correct I’ll have to spend my time with google searches grrrr. Thanks Much.
- The topic ‘query_posts codex correct or not?’ is closed to new replies.