Created
October 11, 2013 00:06
-
-
Save guzuri/6927648 to your computer and use it in GitHub Desktop.
search.phpを読みこむデータによって振り分ける
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
//function.phpに追記 | |
add_filter('template_include','custom_search_template'); | |
function custom_search_template($template){ | |
if ( is_search() ) { | |
//表示する投稿タイプを取得→それをsearch-★.phpの★部分に埋め込む | |
$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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment