首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >分类法名称的默认模板

分类法名称的默认模板
EN

Stack Overflow用户
提问于 2014-06-23 12:42:36
回答 2查看 302关注 0票数 0

我一直在测试分类法。我使用taxonomy.php或分类法-{分类法}.php或分类法-{分类法}-{term}.php来处理分类法文件。例如:

localhost/cars/i 20/其中“cars”是分类法,“i20”是术语。我让它用分类法-cars.php来处理,得到了想要的结果。

但是,我很难获得一个默认的分类名称模板。例如:

localhost/car/在本例中,index.php处理的是这个url,而不是taxonomy.php文件。有人知道是什么模板/文件处理这个问题吗?

EN

回答 2

Stack Overflow用户

发布于 2014-06-23 12:48:50

有关模板黑体如何选择模板的更详细的详细信息,请参见WordPress。

此堆栈交换元将帮助您单击此处

票数 1
EN

Stack Overflow用户

发布于 2014-06-23 13:06:19

你可以使用taxonomy-cars.php并把你的代码听出来

模板结构由两个文件管理,其中文件调用第一优先级并生成层次结构

源文件

模板层次结构函数位于wp-includes/template.php.中。 模板加载层次结构位于wp-includes/template-loader.php.中。

template.php

template-loader.php

代码语言:javascript
运行
复制
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;

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24366244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档