Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search pages ONLY in parent category › Reply To: Search pages ONLY in parent category
June 27, 2019 at 12:43 pm
#23458
Keymaster
Hi Sam,
This might be possible via a custom code. There is a knowledge base on how to get results for specific page parent IDs. If I understand correctly, you have parent/child pages, and you only need the child pages within the results?
In that case, via a minor modification to the original custom code, this should do the trick:
(Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!)
add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 );
function asp_include_only_parent_ids( $args, $id ) {
/**
* Enter the post/cpt prent IDs here. The results will be
* limited to objects with these parent IDs.
*/
$id = get_the_ID();
if ( !empty($id) )
$args['post_parent'] = array($id);
return $args;
}