posts_where Filter for Comment Count and Postmeta
-
Hi – I am trying to modify the following WP_query filter (which works) to use OR for filtering meta_key, meta_value, and meta_compare.
add_filter( 'posts_where', 'filter_where' ); $slide = new WP_query(array('cat' => $parentid )); remove_filter( 'posts_where', 'filter_where' );function filter_where( $where = '' ) { $where .= " AND comment_count > 0 "; return $where; }Below is the best I’ve come up with and I have tried many variations, including trying to make a call without the “comment_count >0” included, but I can’t get it to return anything.
function filter_where( $where = '' ) { global $wpdb; $where .= " AND comment_count > 0 OR ($wpdb->postmeta.meta_key = 'social_stream' AND $wpdb->postmeta.meta_value = '22' AND $wpdb->postmeta.meta_compare = '>=') "; return $where; }Any help will be greatly appreciated. Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘posts_where Filter for Comment Count and Postmeta’ is closed to new replies.