How to remove a plugin filter’s priority on specific loops (custom queries)?

So I have a review plugin that is automatically sorting all my site based on the score rating. It seems here are the filters the plugin is applying globally:

    //Post sorting
    $sort = get_option('rs_sort');
    if ($sort == 'rating') {

        add_filter('posts_fields', 'rs_weighted_fields');
        add_filter('posts_join', 'rs_weighted_join');
        add_filter('posts_groupby', 'rs_weighted_groupby');
        add_filter('posts_orderby', 'rs_weighted_orderby');

    } else if ($sort == 'comments') {
        add_filter('posts_orderby', 'rs_comments_orderby');
    }

}

These filters are taking priority over the whole site. Even some custom loops where I want it to use the wordpress default (sort by newest) and others where I want to sort by random.

Read More

Specifically here is an example loop that I am trying to make:

<?php $custom_query = new WP_Query('category_name=FreaturedIndex&orderby=rand'); ?><?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>

Right now, its just sorting by rating and ignoring the orderby=rand. Is there some code that can be applied to remove these filters by applying it to specific queries?

Thanks for the help!

Related posts

Leave a Reply

1 comment

  1. How about doing remove_filter( 'posts_orderby', 'rs_weighted_orderby' );? If that doesn’t work, you could apply your own filters with higher priorities…but that’s sorta hackey, and I would avoid it if possible.