You are reading...

April 20th

Ignore the headline and keep reading.

So I have a regular loop in my single.php template file. For reason, if a query_post loop is made before the normal loop, it screws up the regular loop. If I put it after the regular loop, it’s fine. It took me three days to discover this problem.

Why?

Go home
  • j

    http://codex.wordpress.org/Template_Tags/query_posts

    “Important note

    The 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.”

  • j

    http://codex.wordpress.org/Template_Tags/query_posts

    “Important note

    The 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.”