Created
January 8, 2013 13:50
-
-
Save hissy/4483968 to your computer and use it in GitHub Desktop.
simple WordPress plugin that enables use of post type search templates
This file contains 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 | |
/* | |
Plugin Name: Enable Post Type Search Template | |
Description: you can use search-{$post_type}.php | |
Author: Takuro Hishikawa | |
Version: 0.1 | |
*/ | |
function enable_post_type_search_template($template){ | |
if ( is_search() ) { | |
$post_types = get_query_var('post_type'); | |
foreach ( (array) $post_types as $post_type ) | |
$templates[] = "search-{$post_type}.php"; | |
$templates[] = 'search.php'; | |
$template = get_query_template('search',$templates); | |
} | |
return $template; | |
} | |
add_filter('template_include','enable_post_type_search_template'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment