exclude posts with a specific custom field and value
Question
How can I exclude posts with a specific custom field and value with this query?
$my_query = new WP_Query( $args = array(
// It should be in the first category of our post:
'category__in' => array( $st_cat ),
// Our post should NOT be in the list:
'post__not_in' => array( $post->ID ),
'posts_per_page' => 8,
'orderby' => 'desc',
));
I already tried this withou sucess:
$my_query = new WP_Query( $args = array(
// It should be in the first category of our post:
'category__in' => array( $st_cat ),
// Our post should NOT be in the list:
'post__not_in' => array( $post->ID ),
'posts_per_page' => 8,
'orderby' => 'desc',
//extra code added without sucess
'meta_query' => array(
'key' => 'city',
'value' => 'true',
'compare' => 'NOT LIKE',
)
));
0
custom-field, post-meta, wp-query
3 years
2019-10-28T15:15:47-05:00
2019-10-28T15:15:47-05:00 0 Answers
82 views
0
Leave an answer