Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Multiple search widgets › Reply To: Multiple search widgets
This makes sense and I’ve applied it to one parent page for parent ID 468. My question is now, how do I add multiple instances of this filter? For example, you’ll see that I’ve got the correctly-working filter set up for a client named NSPRO, parent ID 468. I’ve tested this and the search bar only returns the desired results.
However, if I add a second instance for a client named Accompass – see below – it breaks functions.php:
// — NSPRO —
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(468);
/**
* Search instance IDs you want this code to apply on.
*/
$search_ids = array(1);
// ————————————————–
// ————————————————–
// — !! Do not change anything below this line !! —
// ————————————————–
if ( in_array($id, $search_ids) )
$args[‘post_parent’] = $ids;
return $args;
}
// — accompass —
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(517);
/**
* Search instance IDs you want this code to apply on.
*/
$search_ids = array(2);
// ————————————————–
// ————————————————–
// — !! Do not change anything below this line !! —
// ————————————————–
if ( in_array($id, $search_ids) )
$args[‘post_parent’] = $ids;
return $args;
}