Reset wp_query after custom query
-
Using the ideas I found in this Codex article, I have created my own taxonomy, “character.” Posts (in my case, stories) can be tagged with what characters appear in them, and I’ve got to the point where I can bring up archives of characters by using a URL query like http://example.com?character=bob. It uses archive.php for the moment, since I haven’t made a custom template.
This works great! However, unlike WordPress’s built-in archives, the wp_query variable doesn’t get reset after the query runs. For instance, if I stick a Recent Posts widget in my sidebar, that widget will show only the recent posts that include that character. Of course, if your URL searches by anything else (tag, category, etc), WordPress doesn’t do this, so I figure there’s behavior that resets the query at some point. I’m looking through the WP code trying to find at what point the query is reset, with no luck. Anyone know?
The topic ‘Reset wp_query after custom query’ is closed to new replies.