[WordPress] 外掛分享: Slug as body class

首頁外掛目錄 › Slug as body class
100+
安裝啟用
★★★★★
5/5 分(6 則評價)
4235 天前
最後更新
問題解決
WordPress 3.7+ v1.0 上架:2014-08-08

內容簡介

想要針對每個頁面或文章應用不同的 CSS 樣式嗎?

此外掛會在 HTML 的 body tag 中添加一個獨特的類別。這個類別的格式為「[post_type]-[post_name]」。例如,對於一個 slug(也就是 post_name)是「about」的頁面,它的類別為「page-about」;對於一篇名為「today」的文章,它的類別為「post-today」。目前尚未針對歸檔和分類頁面添加 slug,如果您需要此功能,請告訴我們,我們會加入此功能。

範例

假設您想在您的聯絡頁面上使用紅色標題,透過此外掛,您只需要在 CSS 中加入以下行:

body.page-contact h1 {
color: red;
}

鳴謝

感謝 Damiaan van Vliet 提供這個外掛點子 http://www.albuswebdesign.nl/。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Slug as body class」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Want to have css styling rules for individual pages or posts?
This plugin adds a unique class to the body tag of the html. The added class is formatted as “[post_type]-[post_name]”. For a page with slug (= post_name) “about” it will be “page-about”, and for a post named “today” it will be “post-today”. Currently no slug will be added for archive and category pages. Please let us know if you need this and we will add it.
example
Say you want to have a red title on your contact page. With this plugin all you need to do is add this line to your css:
body.page-contact h1 {
color : red;
}
Acknowledgements
Thanks to Damiaan van Vliet for this plugin idea http://www.albuswebdesign.nl/.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon