Created
June 20, 2016 12:08
-
-
Save SErr0r/f237fb54d05d5d2fdb12e0e226a32052 to your computer and use it in GitHub Desktop.
Override WordPress core template with custom one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Load a custom template rather than the default WordPress usually uses. Handy for custom searches.