How to filter WP_Query for posts having a certain meta-value, without using a Custom Select Query?
I have a custom posttype with meta-key: “open”, and meta-value options: “yes” or “no”.
I would like to show posts only with meta_value = yes, for meta_key = “open”.
function filter_where($where = '') {
$open = "yes";
//$where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
I am not sure from your wording if you hadn’t tried it with query argument or it didn’t work?
Custom Field Parameters in Codex.