Fetch Posts Based on Multiple Ratings foreach Taxonomy

I am setting ratings of posts based on the taxonomies, lets say, now i want to query them based on ratings and taxonomies. an app on PC has rating 10. (meta_key=rating_pc) an app on Android has rating 5. (meta_key=rating_android)

add_action( 'posts_where', 'minscoreaction' );
function minscoreaction( $sql ){

    global $wpdb;
    $minscore = 9;//get_query_var( 'minscore' );
    $platformslug = 'pc';//get_query_var( 'platformlist' );

    if( $minscore ){
        $sql .= $wpdb->prepare( " AND ( $wpdb->postmeta.meta_key LIKE %s AND $wpdb->postmeta.meta_value LIKE %s )", "rating_".$platformslug.'%',$minscore.'%');

PROBLEM: I am getting nothing... means no post. And actually one post exist with rated 9 for pc.

NOTE: I can only use this method to Query Post due to several reasons.


$where .= $wpdb->prepare( " AND $wpdb->posts.post_type LIKE %s ", 'reviews%' );

This returns all the reviews Post Type But This returns nothing

$where .= $wpdb->prepare( " AND $wpdb->postmeta.meta_value LIKE %s ", '9%' );




Use this in functions.php or your template page where you want to use.

    function filter_where( $where = '' ) {
       global $wpdb;
        $minscore = 9;
        $platformslug = 'pc';    
        $posttype =     "reviews";

$where .= " AND ($wpdb->posts.post_type = '".$posttype."')";
$where .= " AND (($wpdb->postmeta.meta_key LIKE '_overall_rating_".$platformslug."%' AND $wpdb->postmeta.meta_value = '".$minscore."')) ";

       return $where;
    add_filter('posts_where', 'filter_where');


use this code on frontend.

$the_query = new WP_Query(array(
    'post_type' => $posttype ,
    'meta_query' => array(
        array('key' => '_overall_rating_' . $platformslug,
            'value' => $minscore)

Need Your Help

How to get a quick status from the Emacs compilation buffer?


By default, emacs 22.1.1 only shows the top of the compilation buffer when you first issue the compile command. I would like it to scroll to the bottom automatically when I use the compile command...

String searching in Linq to Entity Framework

vb.net entity-framework linq-to-entities

I am wanting to create a Where statement within my Linq statement, but have hit a bit of a stumbling block.