這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

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/.

安裝方式

In the WordPress backend, search for the plugin ‘slug-as-body-class’. Install and activate it and you are done.

常見問題集

I miss feature X

Feel free to send us an email, if more people request the same feature we will build it.

使用者評論

2017 年 6 月 19 日
Simple and useful ¿why this isn't in core functions? Many thanks for this plugin.
2017 年 4 月 28 日
I use this plugin on every WP site I build, it's one of the first ones I add. I honestly can't believe that WP doesn't come with this feature natively, it's so handy to quickly add CSS page-by-page, in a more "readable" way than Body ID's.
2016 年 9 月 3 日
This is a very practical and useful plugin for developers. One would think that this functionality is supported natively by Wordpress, but the body classes simply get bloated with attributes. This plugin really helps simplify the process of targeting specific pages.
閱讀全部 6 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Slug as body class〉的開發相關工作。

參與者

將〈Slug as body class〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

1.0

First publication on 2014 August 4