Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › limit to parent for each search instance › Reply To: limit to parent for each search instance
September 16, 2022 at 4:03 pm
#39304
Keymaster
Hi,
Thank you for the details, it helps me a lot!
Using multiple isntances of that code will not work, it will yield an error. There is a much simpler way, of adding an if-else statement to check the search IDs:
add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 );
function asp_include_only_parent_ids( $args, $id ) {
if ( $id == 1 ) {
$args['post_parent'] = array(1105);
} else if ( $id == 2 ) {
$args['post_parent'] = array(1106);
}
return $args;
}
This will add the post parent arguments depending on the search ID.