Is there a way using WordPress to modify the native search function, so that only posts of a specific page template are show. For example:
add_filter(‘pre_get_posts’,’searchfilter’);
function searchfilter($query) {
if ($query->is_search) {
$query->set('post_template','a-template-name'); // Pseudocode
}
return $query;
}
Any help would be appreciated, thanks in advance.
Try this: