我一直在测试分类法。我使用taxonomy.php或分类法-{分类法}.php或分类法-{分类法}-{term}.php来处理分类法文件。例如:
localhost/cars/i 20/其中“cars”是分类法,“i20”是术语。我让它用分类法-cars.php来处理,得到了想要的结果。
但是,我很难获得一个默认的分类名称模板。例如:
localhost/car/在本例中,index.php处理的是这个url,而不是taxonomy.php文件。有人知道是什么模板/文件处理这个问题吗?
发布于 2014-06-23 05:06:19
你可以使用taxonomy-cars.php并把你的代码听出来
模板结构由两个文件管理,其中文件调用第一优先级并生成层次结构
源文件
模板层次结构函数位于wp-includes/template.php.中。 模板加载层次结构位于wp-includes/template-loader.php.中。
if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
$template = false;
if ( is_404() && $template = get_404_template() ) :
elseif ( is_search() && $template = get_search_template() ) :
elseif ( is_front_page() && $template = get_front_page_template() ) :
elseif ( is_home() && $template = get_home_template() ) :
elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
elseif ( is_tax() && $template = get_taxonomy_template() ) :
elseif ( is_attachment() && $template = get_attachment_template() ) :
remove_filter('the_content', 'prepend_attachment');
elseif ( is_single() && $template = get_single_template() ) :
elseif ( is_page() && $template = get_page_template() ) :
elseif ( is_category() && $template = get_category_template() ) :
elseif ( is_tag() && $template = get_tag_template() ) :
elseif ( is_author() && $template = get_author_template() ) :
elseif ( is_date() && $template = get_date_template() ) :
elseif ( is_archive() && $template = get_archive_template() ) :
elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
elseif ( is_paged() && $template = get_paged_template() ) :
else :
$template = get_index_template();
endif;
/**
* Filter the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
if ( $template = apply_filters( 'template_include', $template ) )
include( $template );
return;
endif;
https://stackoverflow.com/questions/24366244
复制