Add URL Slugs as Body Classes

Add URL Slugs to `<body>` Class

Author:Aaron T. Grogg (profile at wordpress.org)
WordPress version required:3.1
WordPress version tested:4.2.2
Plugin version:1.3
Added to WordPress repository:25-02-2012
Last updated:15-05-2015
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:96
Rated by:5
Plugin URI:http://aarontgrogg.com/2012/02/24/wordpress-p...
Total downloads:5 382
Active installs:900+
plugin download
Click to start download

This plug-in takes the URL, chops it into pieces, and adds each "piece" as an additional class to the body tag.

Meaning, if your page's URL is: http://www.example.com/2012/02/24/wordpress-plugin-add-url-slugs-as-body-classes/ Your page's body tag would have at least these classes:

2012 02 24 wordpress-plugin-add-url-slugs-as-body-classess

It gets much stronger when you start thinking about Categories or nested Pages:

http://www.example.com/category/wordpress/

which would add:

category wordpress

while:

http://www.example.com/movies/star-trek/wrath-of-khan/

would add:

movies star-trek wrath-of-khan

This allows you to very easily add custom CSS and/or JS to these pages based on these new CSS classes.

Please let me know if you have any questions/suggestions/thoughts, Atg http://aarontgrogg.com/ aarontgrogg@gmail.com


FAQ
ChangeLog