how limit comments amount in wp_query ? i'm using add_filter('pre_get_posts','search_filter'); ,
$query->set('orderby','date'); $query->set('order','desc'); to limit wp search query. limit amount of search posts relative amount of comments have. example search posts have number of comments in range of 0 15.
i have used appropriate wp_query parameters task:
$from=0; $to=50; $meta=array(); array_push($meta,array('key' => 'comments_amount','value' => $from,'compare' => '>=','type' => 'numeric')); array_push($meta,array('key' => 'comments_amount','value' => $to,'compare' => '<=','type' => 'numeric')); $query->set('meta_query',$meta); you can write function , call by:
add_filter('pre_get_posts','searchfilter'); passing $query function parameter.
Comments
Post a Comment