Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Results field issues › Reply To: Results field issues
Hi,
Thank you for the details!
So, the main issue here was, that there were number of category exclusions/inclusions set, but it just caused more issues – because the attorneys are not actually in the “attorneys” category, some of them are in sub-categories, some of them not even categorized.
The easiest, best and fastest solution to this was adding a custom code to the function.php file in your theme directory:
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.
*/
$ids = array(2321);
/**
* Search instance IDs you want this code to apply on.
*/
$search_ids = array(3);
// --------------------------------------------------
// --------------------------------------------------
// -- !! Do not change anything below this line !! --
// --------------------------------------------------
if ( in_array($id, $search_ids) )
$args['post_parent'] = $ids;
return $args;
}
This code will force the attorneys search (id=3) to only show items, where the parent page is the “Attorneys” page (id=2321), and that is it.
Please keep a copy of this code, as a theme update may remove it automatically. I hope this helps!