Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › limit search › Reply To: limit search
October 6, 2022 at 2:45 pm
#39540
Keymaster
Hi,
Thank you very much for your kind words!
It should not be too difficult, something like this:
add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 );
function asp_include_only_parent_ids( $args, $id ) {
if ( $id == 3 ) {
$args['post_parent'] = array(11748);
} else if ( $id == 12 ) {
$args['post_parent'] = array(3239);
}
$args['post_meta_filter'][] = array(
'key' => 'customfield', // meta key
'value' => 'abc'
'operator' => 'LIKE', // You can also try ELIKE here for more strict match
'allow_missing' => false // allow match if this custom field is unset
);
return $args;
}
You may need to try the “ELIKE” operator as well to have an exact field match, as well as try the “allow_missing” argument on true if you want results where this field does not exist.
I hope this helps!