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

Reply To: page only specific search

#26162
Ernest MarcinkoErnest Marcinko
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;
}