I was wondering if there is a way to alter the global wordpress posts query.
Let’s say that I’m in a tags archive. I need to be able to change the order and posts_per_page variables
when I use this:
global $wp_query;
$wp_query->set('order', 'ASC');
It changes the variable, but the posts order is not changed.
Creating another query would do the job, but doing so would require me to use different queries for tags, archives, search results and etc, which is not an option for me.
I hope you understand what it is that I need.
Any ideas on how to solve this?
Thank you!
if you use query_posts() and pass thru your arguments it will modify the loop.
http://codex.wordpress.org/Function_Reference/query_posts