前言介紹
- 這款 WordPress 外掛「Category Template Hierarchy」是 2011-12-12 上架。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2012-03-24,距離現在已有 5087 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 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。
用法
<?php is_parent_category( $category ); ?>
<?p
原文外掛簡介
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 |
延伸相關外掛(你可能也想知道)
Monster Widget 》Monster 外掛將所有 13 個核心小工具整合成一個單一的小工具,讓佈景主題開發人員能夠輕易地創建多個實例。它的設計旨在節省佈景主題開發和審查時間,因為它...。
What Template Am I Using 》這個外掛程式是供主題開發者使用的,它可以顯示當前的模板、文章類型及其他相關的資訊。, 只有使用者擁有 edit_theme_options 權限才能看到這些資訊。, 顯示...。
Block Widgets Monster 》Block Widgets Monster 是一個免費的 WordPress 外掛,可以讓您輕鬆測試多個 WordPress 或 WooCommerce 區塊/傳統小工具。, 以下是支援的小工具清單。, WordP...。WP Fake Image Replacer 》當您開發 WordPress 佈景主題時,需要插入假內容以測試內容是否正確呈現。有時,您可能希望在開發過程中更改圖片大小,而此時您需要重新上載圖片或重新生成縮...。
User Level Themes 》使用者階層主題外掛程式允許網站管理員為擁有或未擁有管理權限的使用者選擇不同的主題。此功能可用於在將訪客重定向到已知的操作主題時安全測試新主題。此外...。
Matty Theme QuickSwitch 》Matty Theme QuickSwitch 外掛可以讓你方便地啟用主題,無需前往 WordPress 管理員中的「外觀 → 主題」畫面。, 在 WordPress 工具列中的新選單會列出網...。
Eazy HTML5 Elements 》Eazy HTML5 Elements 是一個 WordPress 外掛,可以透過簡短代碼顯示大部分的 HTML 元素。, 這讓佈景主題開發人員可以視覺化地預覽 HTML 元素的顯示效果。, Ea...。BuddyPress Monster Widget 》這個外掛基於 Monster Widget 開發,整合了所有 BuddyPress 核心小工具,打造出一個方便主題開發者快速創建多個實例的單一小工具。它的設計初衷是為了在主題...。
bbPress Monster Widget 》此外掛基於Monster Widget製作,整合了所有bbPress核心小工具,方便主題開發者輕鬆地創建多個實例。它旨在節省主題開發和檢閱的時間,減少在側邊欄中填入小工...。
Zodan One-time Login Link 》<b>總結:</b>, 這個 WordPress 外掛可以創建安全、自動登入連結,並且使用一次性登入連結,讓使用者可以無需輸入使用者名稱或密碼就能登入。同...。
Zodan Text Upfunker 》總結:我們創建了一個帶有多個時尚效果的 CSS 動畫外掛程式,通過少量 JavaScript(無 jQuery)實現,以為網站的標題注入創意活力。我們喜歡這些效果,也希望...。ChildMaker AI 》<html>, <h2>ChildMaker AI 外掛總結:</h2>, <p>ChildMaker AI 讓您只需點擊幾下,就能從任何已安裝的主題創建子佈景主題。適合初...。
Zodan Theme Switcher 》```html, <ul>, <li>當我們在開發主題時,我們經常喜歡在舊版本(已啟用)和新版本(正在開發)之間切換主題。有時候不讓其他人注意到。</l...。
WP My Favourites 》WP My Favourites 是一個簡單的 WordPress 外掛,它允許您從後台選擇最佳的文章、頁面、評論和媒體,並在需要時在您的網站中提取它們。它還允許您使用拖放方...。Line In Typography for WordPress 》“你知道的,網格。” #冷門電影語錄, 此外掛可提供一個12或16列流動式網格疊加,以便在製作流動式或響應式網站時,檢查您的位置設定。, 此外,它...。
