对我来说,该解决方案是可行的(与Bainternet的解决方案相同,但在“post\\u type”之后没有“[]”):
<input type="hidden" name="post_type" value="photo">
<input type="hidden" name="post_type" value="video">
并根据帖子类型(在functions.php上)获取搜索结果的特定模板:
function search_template_chooser($template) {
global $wp_query;
$post_type = get_query_var(\'post_type\');
if( $wp_query->is_search && $post_type == \'photo\' || $wp_query->is_search && $post_type == \'video\' ) {
return locate_template(\'search-media.php\');
}
return $template;
}
add_filter(\'template_include\', \'search_template_chooser\');