Skip to content

Instantly share code, notes, and snippets.

@SErr0r
Created June 20, 2016 12:08
Show Gist options
  • Save SErr0r/f237fb54d05d5d2fdb12e0e226a32052 to your computer and use it in GitHub Desktop.
Save SErr0r/f237fb54d05d5d2fdb12e0e226a32052 to your computer and use it in GitHub Desktop.
Override WordPress core template with custom one
<?php
function custom_search_template($template) {
global $wp_query;
$post_type = get_query_var('post_type');
if (!$wp_query->is_admin
&& $wp_query->is_search
&& isset($post_type)
&& $post_type === 'faq') {
return locate_template('templates/faq-search.php');
}
return $template;
}
add_filter('template_include', 'custom_search_template');
?>
@SErr0r
Copy link
Author

SErr0r commented Jun 20, 2016

Load a custom template rather than the default WordPress usually uses. Handy for custom searches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment