Your syntax is complete wrong in your meta_query
. A key/value pair in an array should be in the format of 'key' => 'value'
. Your format is 'key', 'value'
which in context of an array translate to 0 => 'key', 1 => 'value'
. That is why your meta_query
does not work.
Your failure is also due to not very good housekeeping. As your meta_query
is written, it is hard to properly read it and because of that you miss obvious bugs.
Lets rewrite that section in a more readable way
$meta_query = [
[
'key' => 'job_status',
'value' => 'open',
'compare' => '!='
]
];
$query->set( 'meta_query', $meta_query );
As you can see, my code is easy to read, and very easy to spot obvious bug.
EDIT
If you need to add another key/value pair in your meta_query
, you can simply just add another array.
$meta_query = [
[
'key' => 'job_status',
'value' => 'open',
'compare' => '!='
],
[
'key' => 'another key',
'value' => 'another value',
'compare' => '!='
]
];
$query->set( 'meta_query', $meta_query );