I have modified a WordPress query.
I need to exclude three values but cannot figure out how to do it. I have read lots of people passing more than one value to match but not to exclude. I have tried several things across several hours.
$popularpost = new WP_Query( array( 'posts_per_page' => '12',
'cat' => $cat_id,
'posts_type' => 'post',
'paged' => $paged,
'meta_key' => 'post_price',
'meta_value' =>'SWAP', 'FREE', 'WANTED',
'meta_compare' => '!=',
Any help is greatly appreciated.
I was able to get this working, heres the code I used in case anyone is interested
There is an issue here:
In this case
meta_value
is set toSWAP
.FREE
andWANTED
are just separate entries in the array. Writing your code out like this reveals the problem:I think this is what you want: