How can I create a search bar for a page that searches only in particular page IDs? This shouldn't affect the search bar on other pages.
I tried the following:
add_filter( 'pre_get_posts', 'pregetposts_forspecificpage' );
function pregetposts_forspecificpage($query){
if ($query->is_search) {
$query->set('post_type', 'page');
$query->set('post__in', array(22103,22121));
}
return $query;
}
But this affects search bars used on other pages.