Add URL Slugs to body Class
As of April 2026, Add URL Slugs as Body Classes is a WordPress body plugin with 800 active installations and a 4.8/5 rating from 5 reviews. It has been downloaded 6.6K+ times in total. Requires WordPress 3.1+ and PHP false+. Available on WordPress.org since 2012. Last updated 10 years ago — may have compatibility concerns. Top alternative: Head & Footer Code.
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/sug…
| WordPress | 3.1+ requiredTested up to 4.2.39 |
| PHP | false+ required |
2015-05-15:
* Tested & verified in WP 4.2.2, and added a few FAQs
Plugin data sourced from WordPress.org. Analysis and metrics by PluginSift.