前言介紹
- 這款 WordPress 外掛「Category Template Hierarchy」是 2011-12-12 上架。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2012-03-24,距離現在已有 4789 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
- 有 3 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
theme | category | template | hierarchy | theme development |
內容簡介
這款外掛新增了幾個範本以供選擇:
child-of-category-{slug}.php
category-{slug}.php
child-of-category-{id}.php
category-{term_id}.php
parent-category.php
child-category.php
category.php
archive.php
index.php
這擴充了主題模組的模板層次結構,特別是對於分類而言。主題開發人員
現在可以很容易地為具有子分類、父分類和具有特定父分類的子分類建立不同的範本。
此外,此外掛還提供了四(4)個新的條件式模板標籤:
is_child_category();
is_parent_category();
is_child_of_category();
is_parent_of_category();
只要啟用此外掛,這些函數就可供任何主題或外掛使用。
關於這些功能的詳細文件說明,請參閱本自述檔案的「開發人員註記:
條件式標籤」章節。
注意:此外掛實際上並不會建立 parent-category.php、child-category.php
或任何相關的範本,而是修改了原生的模板層次結構,以允許主題開發人員為父分類和子分類創建特定的範本。
開發人員註記:模板層次結構
以下是針對分類頁可用的範本清單,擴充了原生的模板層次結構。
child-of-category-{slug}.php
category-{slug}.php
child-of-category-{id}.php
category-{term_id}.php
parent-category.php
child-category.php
category.php
archive.php
index.php
只有在當前類別是父類別或子類別時,父模板和子模板才會變得可用。
注意:此外掛實際上並不會建立 parent-category.php、child-category.php
或任何相關的範本,而是修改了原生的模板層次結構,以允許主題開發人員為父分類和子分類創建特定的範本。
開發人員註記:條件式標籤
這款外掛提供了兩個額外的條件式標籤,
行為與 WordPress 中的其他條件式標籤類似。開發人員可以使用這款外掛
中提供的以下函數:
is_parent_category()
is_child_category()
is_child_of_category()
is_parent_of_category()
說明(部分 1)
is_parent_category() 和is_child_category()條件式標籤檢查顯示中的頁面
(或傳遞的參數)是否為具有子分類(例如父類別)、具有父親(例如子類別)的
類別。 它們是布林函數,也就是說它們只會傳回TRUE 或 FALSE。
用法
原文外掛簡介
Adds several new templates to the template hierarchy:
child-of-category-{slug}.php
category-{slug}.php
child-of-category-{id}.php
category-{term_id}.php
parent-category.php
child-category.php
category.php
archive.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:
is_child_category();
is_parent_category();
is_child_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
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
category-{slug}.php
child-of-category-{id}.php
category-{term_id}.php
parent-category.php
child-category.php
category.php
archive.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
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. In a similar fashion to how one
might use is_category() or cat_is_ancestory_of(),
developers may, with this plugin, use the following functions:
is_parent_category()
is_child_category()
is_child_of_category()
is_parent_of_category()
Description (part 1)
The is_parent_category() and is_child_category() conditional tags check if
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.
Usage
Parameters
$category (integer/string/object) (optional) Category ID, Category Slug, Category Object. Default: Current Category
Note: Unlike is_category(), these functions will not take arrays of categories or category titles. I’ll work on that. Sorry.
Return Values
(boolean) True on success, false on failure.
Examples
is_parent_category()
is_child_category()
// When any parent/child category archive page is being displayed
is_parent_category( '9' );
is_child_category( '9' );
// When the archive page for Category 9 is being displayed AND its a parent/child.
is_parent_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.
Description (part 2)
The is_parent_of_category() and is_child_of_category() conditional tags
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.
Usage
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
*
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. If $direct_descendant is set to false it will return the same results as cat_is_ancestor_of().
Examples
The following function will return True…
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).
is_child_of_category(12);
// When the current category is a direct child of the category whose ID is '12'.
is_child_of_category('tv-shows')
// When the current category is a direct child of the category with the slug 'tv-shows' (can also be category ID's).
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). This may come in handy when manipulating categories while not in a category template.
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. (uses cat_is_ancestor_of())
is_child_of_category('tv-shows', null, false);
// When the current category is a descendant of the 'tv-shows' category at any level. (uses cat_is_ancestor_of())
is_parent_of_category(13);
// When the current category is the direct parent of a category with the ID '13'.
is_parent_of_category('dexter');
// When the current category is the direct parent of the category with the slug 'dexter'.
Backward Compatibility
The changes this plugin makes to the template hierarchy are significantly different
from that in 1.0.5 and before. 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.
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.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Category Template Hierarchy」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0.5 |
延伸相關外掛(你可能也想知道)
Kirki Customizer Framework 》 , 新增 -現在可使用 Kirki PRO , Kirki讓佈景主題開發者更快速、更輕鬆建立佈景主題。, Kirki 提供超過 30 個自訂控制,範圍從簡單的滑桿到具有 Google ...。
Child Theme Configurator 》res and options to help you take complete control of your WordPress site's visual appearance. With PRO, you can handle any plugin's CSS styles, pre...。
Easy Theme and Plugin Upgrades 》WordPress 具有透過提供壓縮檔案安裝主題和外掛的內置功能。不幸的是,您無法使用相同的過程升級主題或外掛。相反,當試圖使用壓縮檔案升級時,WordPress 會...。
Widget Shortcode 》這個短碼需要小工具的ID,但不需要猜測,外掛會為你生成代碼。如果你想要覆蓋小工具的標題,你可以使用 "title" 參數:, [widget id=”text-1″...。
All In One Favicon 》查看最新的WordPress交易以優化您的網站。, All In One Favicon為您的網站和管理頁面添加favicon。, 您可以使用您已經上傳的favicon或使用內置的上傳機制將fa...。
Theme Editor 》主題編輯器 (Theme Editor) 允許您編輯主題文件、建立資料夾、上傳檔案,以及在主題和外掛中移除任何檔案和資料夾。您可以直接自訂主題和外掛。, 升級至專業...。
Download Plugins and Themes in ZIP from Dashboard 》在儀表板下載外掛和佈景主題外掛可讓您直接從管理儀表板下載已安裝的外掛和佈景主題 ZIP 檔案而無需使用 FTP。, 外掛中沒有必須的設置 - 安裝後,所有以下 Do...。
Cryout Serious Theme Settings 》這個外掛是為了與我們的 Nirvana、Tempera、Parabola 和 Mantra 主題互相運作,並在目前的 WordPress 版本上啟用其進階設定頁面。, 相容性, 無論 WordPress ...。
WP Updates Notifier 》這個外掛程式會監控你的 WordPress 安裝,並會在核心、外掛程式和佈景主題更新時發送電子郵件通知你。如果你不經常登入 WordPress 管理員,或支援客戶的網站...。
Disable auto-update Email Notifications 》自 WordPress 5.5 起,若您已啟用外掛或佈景主題自動更新功能,當外掛或佈景主題自動更新成功或失敗時,您將會收到一封電子郵件通知。, 如果你管理多個網站,...。
WP Child Theme Generator 》WP子佈景主題產生器是一個非常簡單易用的外掛,可用於為WordPress CMS支援的任何佈景主題創建子佈景主題。使用多種選項創建子佈景主題,您可以輕鬆地創建和自...。
Multi Device Switcher 》Multi Device Switcher外掛允許您為設備(智能手機、平板電腦、手機、遊戲和自定義)設置單獨的佈景主題。, 此外掛可以偵測到使用者代理(UserAgent)是否正在...。
Multiple Themes 》重要提示:支援服務已移至 ZATZLabs 網站,不再於 WordPress.org 論壇提供。如需開發者迅速回覆,請提交請求單。, 此外掛設定提供多種選擇方式,可讓您選擇要...。
Disable All WordPress Updates 》這個外掛可以完全停用 WordPress 的主題、外掛和核心更新檢查系統。該插件防止 WordPress 檢查更新,包括 cronjobs,並防止顯示任何通知訊息。, 很重要的是,...。
WP-LESS 》LESS 是一種基於 CSS 的樣板語言。它提供了許多增強功能,以加速開發並使維護更容易。, 主題開發人員甚至可以捆綁該外掛而不用擔心衝突:只需包含特殊的 boot...。