This plugin hasn’t been tested with the latest three major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Slug as body class

Description

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

Installation

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

FAQ

I miss feature X

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

Reviews

19 June 2017
Simple and useful ¿why this isn't in core functions? Many thanks for this plugin.
28 April 2017
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.
3 September 2016
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.
Read all 6 reviews

Contributors and Developers

“Slug as body class” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Slug as body class” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Change Log

1.0

First publication on 2014 August 4