Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › page only specific search › Reply To: page only specific search
March 6, 2020 at 5:08 pm
#26162
Keymaster
I assume you mean non-direct descendants of that page (all child pages).
Well, I am not sure if that is possible, but this may work instead of the previous code:
add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 );
function asp_include_only_parent_ids( $args, $id ) {
$parentid = 7783;
$search_ids = array(1, 2);
// No change below
$child = new WP_Query( array('child_of' => $parentid, 'post_type' => 'page', 'fields' => 'ids) );
if ( is_array($child->posts) && count($child->posts) >0 && in_array($id, $search_ids) )
$args['post_in'] = $child->posts;
return $args;
}