Automated Indexes and wp_reset_query()

I’ve made a code change to the WordPress indexing system outlined in my previous post. If you had problems with the template, try the new code.

What I’ve done is add the wp_reset_query() function to the end of the loop that gathers the pages. This can avoid conflicts with other code that may be running in your templates.

In general, it’s good advice to any of you WordPress coders out there who use the query_posts() function, or in general run custom instances of the $wp_query object in plugins or templates. When you’re done with whatever you’re doing, put things back the way you found them by following it up with a call to wp_reset_query().

(By the way — it isn’t terribly well documented yet, but the original discussion leading to the function’s creation can be found at http://trac.wordpress.org/ticket/4741.)

Post a Comment

Your email is never published nor shared.

Subscribe without commenting