Created
September 26, 2017 08:17
-
-
Save swoboda/f474c88539f93b17ddbdabf7098f0a22 to your computer and use it in GitHub Desktop.
search-template-post-type.php
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 | |
add_filter( 'template_include', 'wpdesk_search_template' ); | |
// Docs Live Search Template | |
function wpdesk_search_template( $template ) { | |
global $wp_query; | |
$post_type = get_query_var('post_type'); | |
if( $wp_query->is_search && $post_type == 'docs' ) { | |
if( file_exists( STYLESHEETPATH . '/search-docs.php') ) { | |
return STYLESHEETPATH . '/search-docs.php'; | |
} else { | |
return TEMPLATEPATH . '/search.php'; | |
} | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment