[wordpress插件] Category Template Hierarchy类别模板层次结构

wordpress 插件 文章 2020-03-18 18:50 503 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Adds several new templates to the template hierarchy:

在模板层次结构中添加几个新模板:

    • child-of-category-{slug}.php
    • child-of-category- {slug} .php

    • category-{slug}.php
    • category- {slug} .php

    • child-of-category-{id}.php
    • child-of-category- {id} .php

    • category-{term_id}.php
    • category- {term_id} .php

    • parent-category.php
    • parent-category.php

    • child-category.php
    • child-category.php

    • category.php
    • category.php

    • archive.php
    • archive.php

    • index.php
    • index.php

    This greatly extends the native hierarchy of theme templates with regard to

    这大大扩展了主题模板的本机层次结构

    categories.

    类别。

    Theme developers can now easily create separate templates for

    主题开发人员现在可以轻松地为
    创建单独的模板

    categories with children, with parents, and children of specific parents.

    带有孩子,有父母和特定父母的孩子的类别。

    Additionally makes available four (4) new conditional template tags:

    另外还提供了四(4)个新的条件模板标记:

      • is_child_category();
      • is_child_category();

      • is_parent_category();
      • is_parent_category();

      • is_child_of_category();
      • is_child_of_category();

      • is_parent_of_category();
      • is_parent_of_category();

      These functions are available for use in any theme or plugin as along as this

      这些功能可与此一起用于任何主题或插件中。

      plugin is active.

      插件处于活动状态。

      For detailed documentation of these functions see the

      有关这些功能的详细文档,请参见

      ‘Developer Notes: Conditional Tags’ section of this readme file.

      此自述文件的“开发人员说明:条件标签”部分。

      Note: This plugin does not actually create parent-category.php, child-category.php

      注意:此插件实际上不会创建parent-category.php,child-category.php

      or any of their related templates – rather it modifies the native template hierarchy

      或其任何相关模板–而是修改了本机模板层次结构

      to allow theme developers to create specific templates for parent and child categories.

      允许主题开发人员为父类别和子类别创建特定的模板。

      Developer Notes: Template Hierarchy

      开发人员说明:模板层次结构

      What follows are is the modified list of templates available for category pages.

      以下是可用于类别页面的模板的修改列表。

      These expand upon the native Template Hierarchy.

      这些扩展了原生的模板层次结构

        • child-of-category-{slug}.php
        • child-of-category- {slug} .php

        • category-{slug}.php
        • category- {slug} .php

        • child-of-category-{id}.php
        • child-of-category- {id} .php

        • category-{term_id}.php
        • category- {term_id} .php

        • parent-category.php
        • parent-category.php

        • child-category.php
        • child-category.php

        • category.php
        • category.php

        • archive.php
        • archive.php

        • index.php
        • index.php

        The parent and child templates only become available if the current category is

        仅当当前类别为
        时,父模板和子模板才可用

        a parent or a child respectively.

        父母或孩子。

        Note: This plugin does not actually create parent-category.php, child-category.php

        注意:此插件实际上不会创建parent-category.php,child-category.php

        or any of their related templates – rather it modifies the native template hierarchy

        或其任何相关模板–而是修改了本机模板层次结构

        to allow theme developers to create specific templates for parent and child categories.

        允许主题开发人员为父类别和子类别创建特定的模板。

        Developer Notes: Conditional Tags

        开发人员说明:条件标记

        With this plugin comes two additional conditional tags

        此插件附带两个附加的条件标记

        which behave much like any other in WordPress.

        其行为与WordPress中的其他行为非常相似。

        In a similar fashion to how one

        以与
        类似的方式

        might use is_category() or is_category()

        Function_Reference/cat_is_ancestor_of" rel="nofollow">cat_is_ancestory_of(),

        Function_Reference / cat_is_ancestor_of“ rel =” nofollow“> cat_is_ancestory_of(),

        developers may, with this plugin, use the following functions:

        开发人员可以通过此插件使用以下功能:

          • is_parent_category()
          • is_parent_category()

          • is_child_category()
          • is_child_category()

          • is_child_of_category()
          • is_child_of_category()

          • is_parent_of_category()
          • is_parent_of_category()

          Description (part 1)

          说明(第1部分)

          The is_parent_category() and is_child_category() conditional tags check if

          is_parent_category() is_child_category()条件标签检查是否

          the page being displayed (or passed as an argument) is of a category that has

          显示(或作为参数传递)的页面属于具有
          的类别

          children (e.g. is a parent category) has a parent (is a child), respectively.

          子项(例如,是父类别)分别具有父项(是子项)。

          They are boolean functions, meaning they return either TRUE or FALSE.

          它们是布尔函数,意味着它们返回TRUE或FALSE。

          Usage

          用法

            <?php is_parent_category($ category); 

          ?>

          ?>

          <?php is_child_category($ category);

          ?>

          ?>

          Parameters

          参数

          $category (integer/string/object) (optional) Category ID, Category Slug, Category Object.

          $ category(整数/字符串/对象)(可选),类别ID,类别Slug,类别对象。

          Default: Current Category

          默认值:当前类别

          Note: Unlike is_category(), these functions will not take arrays of categories or category titles.

          注意:与is_category()不同,这些函数将不包含类别或类别标题的数组。

          I’ll work on that.

          我会努力的。

          Sorry.

          抱歉。

          Return Values

          返回值

          (boolean) True on success, false on failure.

          (布尔值)成功则为true,失败则为false。

          Examples

          示例

          is_parent_category()

            is_parent_category()

          is_child_category()

          is_child_category()

          // When any parent/child category archive page is being displayed

          //当显示任何父/子类别存档页面时

          is_parent_category( '9' );

          is_parent_category('9');

          is_child_category( '9' );

          is_child_category('9');

          // When the archive page for Category 9 is being displayed AND its a parent/child.

          //当显示类别9的存档页面及其父项/子项时。

          is_parent_category( 'blue-cheese' );

          is_parent_category('blue-cheese');

          is_child_category( 'blue-cheese' );

          is_child_category('blue-cheese');

          // When the archive page for the Category with Category Slug "blue-cheese" is being displayed AND its a parent/child.

          //当显示类别标签为“ blue-cheese”的类别的存档页面及其父/子页面时。

          Description (part 2)

          说明(第2部分)

          The is_parent_of_category() and is_child_of_category() conditional tags

          is_parent_of_category() is_child_of_category()条件标记

          check if a given category has a parent or child relationship to the current

          检查给定类别是否与当前类别具有父或子关系

          category or a category passed as its second parameter.

          类别或作为其第二个参数传递的类别。

          They are

          他们是

          boolean functions, meaning they return either TRUE or FALSE.

          布尔函数,表示它们返回TRUE或FALSE。

          Usage

          用法

            <?php is_parent_of_category($ child_category,$ parent_category,$ direct_descendant); 

          ?>

          ?>

          <?php is_child_of_category($ parent_category,$ child_category,$ direct_descendant);?>

          Parameters

          参数

          (object/string/integer) (required) Category of the would-be parent/child respectively.

          (对象/字符串/整数)(必填),分别是可能的父/子类别。

          (object/string/integer) (optional) Category of the would-be child/parent respectfully.

          (对象/字符串/整数)(可选)分别为可能的孩子/父母的类别。

          Default: Current Category

          默认值:当前类别

          (boolean) (optional) Whether or not the child should be a direct child of the parent.

          (布尔值)(可选)孩子是否应该是父母的直系孩子。

          Default: True
           

          默认值:True
           

          *

          *

          Return Values

          返回值

          (boolean) If the $direct_descendant flag set to true, function returns true if the child is a direct descendant of the parent, if child is no direct it will return false.

          (boolean)如果$ direct_descendant标志设置为true,则如果子代是父代的直接后代,则函数返回true;如果子代不是直接父代,则函数将返回false。

          If $direct_descendant is set to false it will return the same results as cat_is_ancestor_of().

          如果$ direct_descendant设置为false,它将返回与cat_is_ancestor_of()相同的结果。

          Examples

          示例

          The following function will return True…

          以下函数将返回True…

          is_child_of_category(0);

            is_child_of_category(0);

          // When a top level category is being displayed, zero being the parent id value for top level categories (e.g. categories with no parents).

          //当显示顶级类别时,零是顶级类别(例如,没有父母的类别)的父ID值。

          is_child_of_category(12);

          is_child_of_category(12);

          // When the current category is a direct child of the category whose ID is '12'.

          //当前类别是ID为'12'的类别的直接子代时。

          is_child_of_category('tv-shows')

          is_child_of_category('电视节目')

          // When the current category is a direct child of the category with the slug 'tv-shows' (can also be category ID's).

          //当当前类别是带有“ tv-shows”子句(也可以是类别ID)的类别的直接子代时。

          is_child_of_category('tv-shows', 'dexter');

          is_child_of_category('tv-shows','dexter');

          // When the category with slug 'dexter' is a direct child of the category with the slug 'tv-shows' (can also be category ID's).

          //如果带有“ sug”“ dexter”的类别是带有“ sv-shows”的类别的直接子代(也可以是类别ID)。

          This may come in handy when manipulating categories while not in a category template.

          当不在类别模板中操作类别时,这可能会派上用场。

          is_child_of_category('tv-shows', 'dexter', false);

          is_child_of_category('tv-shows','dexter',false);

          // When the category with the slug 'dexter' is a descendant of the category 'tv-shows' at any level.

          //当类别为“ dexter”的子类别是任何级别的“电视节目”类别的后代时。

          (uses cat_is_ancestor_of())

          (使用cat_is_ancestor_of())

          is_child_of_category('tv-shows', null, false);

          is_child_of_category('电视节目',null,false);

          // When the current category is a descendant of the 'tv-shows' category at any level.

          //当前类别是任何级别的“电视节目”类别的后代。

          (uses cat_is_ancestor_of())

          (使用cat_is_ancestor_of())

          is_parent_of_category(13);

          is_parent_of_category(13);

          // When the current category is the direct parent of a category with the ID '13'.

          //当前类别是ID为'13'的类别的直接父级时。

          is_parent_of_category('dexter');

          is_parent_of_category('dexter');

          // When the current category is the direct parent of the category with the slug 'dexter'.

          //当前类别为子类别“ dexter”的直接父类别时。

          Backward Compatibility

          向后兼容

          The changes this plugin makes to the template hierarchy are significantly different

          此插件对模板层次结构所做的更改明显不同

          from that in 1.0.5 and before.

          从1.0.5及之前的版本开始。

          If you prefer to use that version please find it

          如果您想使用该版本,请找到它

          in the Older Versions in the WordPress plugins directory, it is tagged as 1.0.5.

          在WordPress插件目录的“较旧版本”中,该标签被标记为1.0.5。

          While I do not actively support to QA the older version, I would gladly take a

          虽然我不积极支持旧版本的质量检查,但我很乐意接受

          look at any future bugs that crop up and are reported.

          查看将来会出现并报告的所有错误。

安装步骤

    1. Upload plugin-name.php to the /wp-content/plugins/ directory
    2. plugin-name.php 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

下载地址
https://downloads.wordpress.org/plugin/category-template-hierarchy.zip
-EOF-

AI助手支持GPT4.0