Skip to content

Instantly share code, notes, and snippets.

@nicholasohrn
Last active August 29, 2015 14:01
Show Gist options
  • Save nicholasohrn/c996017a2d2284491b29 to your computer and use it in GitHub Desktop.
Save nicholasohrn/c996017a2d2284491b29 to your computer and use it in GitHub Desktop.
Force CPT template for search on CPT
function force_cpt_template_for_search($template) {
if(is_search() && is_post_type_archive() && ($_template = get_post_type_archive_template())) {
$template = $_template;
}
return $template;
}
add_filter('template_include', 'force_cpt_template_for_search');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment