I am trying to override a query in a loop which exists in other plugin. I created an extension to override that loop using a hook that exists in the plugin.

The plugin query:

query_posts ($args);
Some codes
the loop

In my extension:

function geo_srt_reset_query(){
    global $wp_query;
    $wp_query->set('orderby','meta_value_num title');

    query_posts($wp_query->query_vars); // i tried with this line and without it.

The problem is that the query results or affected doesn't change. So if you think you can offer some help, please don't hesitate.

  • 1
    It is of absolute no use declaring the $wp_query global in your code when you just stuff everything up later on with the use of query_posts. IMHO, the plugin you are using are a heap of crap, sorry to say and you would be better of without it. Golden rule, never ever use query_posts. I would rewrite the complete plugin to bring it up to standard :-) – Pieter Goosen Mar 1 '15 at 8:26

Your question is incomplete and you have omitted all the context for some weird reason.

I hope we agree that query_posts() is a bad idea. There's enough been said on it:

When to use WP_query(), query_posts() and pre_get_posts

Having said that, have you tried wp_reset_postdata, wp_reset_query or rewind_posts? I have no idea what you are doing here, but you can read this and figure which one to use:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.