Hi @mmcginnis
It’s definitely possible, but the solution may vary depending on your WordPress setup.
For the simplest case, you don’t even need the Search Exclude plugin. Try adding following code to your functions.php:
add_filter('pre_get_posts', function ($query) {
$shouldApply =
(!is_admin() || (defined('DOING_AJAX') && DOING_AJAX))
&& $query->is_search;
if ($shouldApply) {
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'status',
'compare' => '!=',
'value' => 'inactive',
),
array(
'key' => 'status',
'compare' => 'NOT EXISTS',
'value' => ''
),
));
}
return $query;
});
Please let me know if this worked for you. If not, feel free me to reach me out by email [email protected] and we’ll figure it out.
Cheers!
-
This reply was modified 7 years, 8 months ago by
pronskiy.
Thank you so much @pronskiy for the quick reply – that worked perfectly!! Much appreciated.