前言介紹
- 這款 WordPress 外掛「Ambrosite Body Class Enhanced」是 2010-04-25 上架。
- 目前有 300 個安裝啟用數。
- 上一次更新是 2011-07-03,距離現在已有 5054 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.8 以上版本才可以安裝。
- 有 5 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
body | page | post | classes | body_class |
內容簡介
啟用此外掛後,body_class 樣板標籤會輸出五個額外的類別。
單一文章 (is_single) :
postname-[永久連結別名]
single-[分類別名]
parent-[上層分類別名] (包含所有上層及祖先分類別名,任何深度的階層)
頁面 (is_page) :
pagename-[永久連結別名]
分類別名 (is_archive and is_category) :
parent-category-[上層分類別名] (包含所有上層及祖先分類別名,任何深度的階層)
自訂分類法
從版本1.3開始,該外掛現在支援自訂階層式分類法。新的 body 類別遵循以下形式:
單一文章 (is_single) :
single-[taxonomy]-[分類名稱別名]
parent-[taxonomy]-[上層分類名稱別名] (包含所有上層及祖先分類別名,任何深度的階層)
分類法檔案 (is_archive and is_tax) :
parent-term-[上層分類名稱別名] (包含所有上層及祖先分類別名,任何深度的階層)
對單獨的文章,類別名稱包含在類別名中,因為我覺得在一個文章被分配到超過一個自定分類法的情況下,以及相同分類器可能出現在兩個或多個分類法中時,區分類別法非常重要。例如,假設您有一個房地產網站,其中紐約市的物業列表有兩個自訂分類法:市區和州。然後類別會像這樣:
single-city-new-york single-state-new-york
多站點支援
從版本1.3開始,該外掛現在支援多站點安裝。如果偵測到多站點安裝,該外掛會在網站每個頁面上輸出以下額外的 body 類別:
site-[站點ID]
範例
如果您有一篇稱為“前10個裝飾點子”、在“聖誕節”類別中且它的上層類別是“假期”且上上層類別為“日曆”的文章,那麼額外的 body 類別如下:
postname-top-10-decorating-ideas single-christmas parent-holidays parent-calendar
為什麼這很有用?因為它使您能夠僅使用 CSS 样式表,而無需編輯模板檔案或創建新樣板,即可對單個文章或頁面以及整個文章分類進行樣式設定。
繼續上面的例子,如果我想要給聖誕節類別中的所有文章添加一個綠色標題(為其增添節日氣氛),我可以使用以下 CSS 選擇器:
body.single-christmas h1 {
color: green;
}
進一步地,假設我想要將一個聖誕樹背景圖像僅附加到“前10個裝飾點子”文章中:
body.postname-top-10-decorating-ideas div.post {
background: url('images/xmas_tree.gif') no-repeat left top;
}
如果我想讓所有分類為假期(聖誕節、感恩節、復活節等)的文章都有帶有金邊的側邊欄,該怎麼做?
body.parent-holidays div#sidebar, /* all posts assigned to a subcategory of Holidays */
body.single-holidays div#sidebar { /* any posts assigned directly to the Holidays category */
border: solid 2px gold;
}
上述僅成為參考,如果您寫 CSS 選擇器有豐富的經驗,您將會發現更多使用新的 body 類別的方法。如需進一步討論,請查看此支援論壇主題:https://wordpress.org/support/topic/393942
原文外掛簡介
When activated, this plugin causes the body_class template tag to output five additional classes.
On single posts (is_single) :
postname-[permalink slug]
single-[category slug]
parent-[parent category slug] (all parent and grandparent categories in a hierarchy of any depth)
On pages (is_page) :
pagename-[permalink slug]
On category archives (is_archive and is_category) :
parent-category-[parent category slug] (all parent and grandparent categories in a hierarchy of any depth)
Custom Taxonomies
As of version 1.3, the plugin now supports custom hierarchical taxonomies. The new body classes take the following form:
On single posts (is_single) :
single-[taxonomy]-[term slug]
parent-[taxonomy]-[parent term slug] (all parent and grandparent terms in a hierarchy of any depth)
On taxonomy archives (is_archive and is_tax) :
parent-term-[parent term slug] (all parent and grandparent terms in a hierarchy of any depth)
For single posts, the taxonomy name is included in the class name, because I felt it was important to be able to distinguish between taxonomies in cases where a post is assigned to more than one custom taxonomy, and when the same term might appear in two or more taxonomies. For example, suppose you had a real estate site with property listings in New York City, and you had two custom taxonomies defined: City and State. Then the classes would look like this:
single-city-new-york single-state-new-york
Multisite Support
As of version 1.3, the plugin now supports multisite installations. If a multisite install is detected, the plugin will output the follow additional body class on every page of the site:
site-[site ID]
Examples
If you have a post titled “Top 10 Decorating Ideas”, in category “Christmas”, with a parent category of “Holidays” and a grandparent category of “Calendar”, the additional body classes will be as follows:
postname-top-10-decorating-ideas single-christmas parent-holidays parent-calendar
Why is this useful? Because it enables you to style individual posts and pages, as well as entire categories of posts, using only CSS, without having to edit the template files or create new templates.
Continuing the above example, if I wanted to give all of the posts in the Christmas category a green heading (to give them some extra holiday cheer), I could use a CSS selector like this:
body.single-christmas h1 {
color: green;
}
Going further, suppose I want to attach a background image of a Christmas tree ONLY to the “Top 10 Decorating Ideas” post:
body.postname-top-10-decorating-ideas div.post {
background: url('images/xmas_tree.gif') no-repeat left top;
}
What if I want all posts categorized under Holidays (Christmas, Thanksgiving, Easter, whatever) to have a sidebar with a gold border?
body.parent-holidays div#sidebar, /* all posts assigned to a subcategory of Holidays */
body.single-holidays div#sidebar { /* any posts assigned directly to the Holidays category */
border: solid 2px gold;
}
These are just a few examples. If you are experienced in writing CSS selectors, you will find many more uses for the new body classes. For further discussion, check this support forum thread: https://wordpress.org/support/topic/393942
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Ambrosite Body Class Enhanced」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
PS Auto Sitemap 》PS Auto Sitemap 是一個 WordPress 外掛,自動從您的 WordPress 網站生成網站地圖頁面。, 對於初學者來說,安裝非常容易;對於專家來說,定制也非常容易。您...。
Post Type Switcher 》這個外掛在文章編輯介面中新增了一個簡單的文章型別下拉選單,讓你可以重新指派任何文章至新的文章型別。你可以在編輯文章時更換文章的型別。, 支援的型別, ...。
Post Duplicator 》這個外掛是用來製作選定文章的完全一模一樣複製。它支援自訂文章類型、自訂分類和自訂欄位。, *注意: 評論不會被複製到新文章。, 這個外掛的目的是為了快速且...。
Optimize Database after Deleting Revisions 》這個外掛是一個「一鍵式」WordPress資料庫清理/優化器。, 主要功能, , 刪除文章、頁面和/或自訂文章類型的修訂版本(您可以選擇保留最近的「X」個修訂版本,...。
Advanced Excerpt 》這個外掛可以改進 WordPress 原有的摘錄文章功能。, , 保留摘錄中的 HTML 標記,並可自選需要保留的標記, 按字元數或字數截斷摘錄, 只計算「真正的」文字(HT...。
Add From Server 》這個外掛提供有限的支援。請不要期望有太多新功能或修正 bug。功能可能隨時被移除。, Add From Server 外掛旨在幫助緩解不好的網站主機所造成的困擾,讓您可...。
Page and Post Clone 》這個外掛可以透過一個按鈕來複製貼文或頁面,現在您不必從零開始進行新頁面或貼文的樣式設計。, 這個外掛的主要功能包括:, , 建立一個頁面複本,保留所有內...。
WP Page Widget 》這款外掛讓小工具的選擇變得更加容易。啟用此外掛後,我們可以選擇要顯示在特定頁面/文章/自訂文章類型中的小工具。, 請注意,使用此外掛時必須啟用側邊欄主題。。
WP Total Hacks 》WP Total Hacks 可以在您的 WordPress 網站上自訂超過 20 個設置。, 此外掛已在 GitHub 上發布。, 一些功能:, 您可以選擇啟用或停用所有項目。, 需要 PHP5!...。
Revision Control 》**本外掛不提供支援。仍可使用,但請勿期待得到支援要求的回應或對「這無法運作」進行回應。**, Revision Control 是 WordPress 的一款外掛,可以讓使用者更...。
Reveal IDs 》WordPress 2.5版本發佈後,所有管理頁面的ID都被刪除了。這應該是因為普通用戶不需要它們。但對於高級WordPress用戶和開發人員來說,這些ID對某些外掛或模板...。
Bulk Delete 》Bulk Delete 是一個 WordPress 外掛,可以根據不同的條件和過濾器批次刪除文章、頁面、附件、使用者和元資料。此外掛支援以下條件和過濾器:, , 刪除文章, , ...。
WP Admin UI Customize 》, 儀表板, 顯示選項標籤, 輸出 - 元網站, 管理工具列 (Toolbar), 側邊選單 (Side menu), 元箱的管理, 登入畫面, 其他功能, , 這些自訂化都是可以實現的。, , ...。
Themify Portfolio Post 》Themify Portfolio Posts 是一個簡單的外掛,允許您展示乾淨版面的專案資訊。簡約而精美,您可以點擊您的圖庫專案的每張圖片,選擇顯示更多細節,例如專案類...。
Essential Content Types 》Essential Content Types 是一個 WordPress 外掛程式,讓您可以在您的網站上以不同的內容/文章類型展示出優秀的內容。這些內容/文章類型可能會被 WordPress ...。