This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: limit to parent for each search instance

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

#39304
Ernest MarcinkoErnest Marcinko
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.