The reason you can’t figure out how to do it is because it’s not possible, at least not without resorting to SQL. Try adding the following to your theme’s functions.php file:
1 2 3 4 5 6 7 8 9 10 | add_filter('posts_where','yoursite_posts_where',10,2); function yoursite_posts_where($where,$query) { global $wpdb; $new_where = " TRIM(IFNULL({$wpdb->postmeta}.meta_value,''))<>'' "; if (empty($where)) $where = $new_where; else $where = "{$where} AND {$new_where}"; return $where; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.