Title: Body class cleaning
Last modified: May 28, 2020

---

# Body class cleaning

 *  [Obje](https://wordpress.org/support/users/harrow/)
 * (@harrow)
 * [6 years ago](https://wordpress.org/support/topic/body-class-cleaning/)
 * Hi there,
 * I’m looking for the best way to “clean” the body classes generated by WordPress
   by default, through functions.php. I’ve found an interesting way to do it here:
 * `https://github.com/billerickson/EA-Genesis-Child/blob/master/inc/wordpress-cleanup.
   php`
 * Getting the following classes :
    ‘singular’, ‘single’, ‘page’, ‘archive’, ‘admin-
   bar’, ‘full-width-content’, ‘content-sidebar’, ‘content’, is already nice but
   it’s a bit restrictive because I’d like to authorize classes like .page-*** dynamically
   for every new page created.
 * Is using something like :
    `$dynamic_pages = "page-". $dynamic_pages;` is a good
   way to achieve it?
 * Thanks by advance for your help !

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [6 years ago](https://wordpress.org/support/topic/body-class-cleaning/#post-12905408)
 * You seem to be contradicting yourself, as you want to clean the classes but then
   you want to add more?
 * I do not see any benefit in removing any classes that WordPress adds, and the
   theme and plugins add the ones they need.
    If you have a use for an additional
   class, structure it the way you need. I would not use `page-` as a prefix, because
   it is already used by WordPress, and is specific to Pages.
 * In my theme, I add a class to represent each post, by using its slug with a prefix
   of ‘name-‘ because that’s the variable name of the slug (`post_name`).
    My theme
   also provides a way to apply theme options per page, and I use the body classes
   to do this.
 *  Thread Starter [Obje](https://wordpress.org/support/users/harrow/)
 * (@harrow)
 * [6 years ago](https://wordpress.org/support/topic/body-class-cleaning/#post-12909970)
 * Hi Joy,
 * Thank you for your reply.
    The only reason I do that is to keep my code as clear
   as possible. Having classes like : “home page-template-default page page-id-90
   single-author singular not-logged-in weaver-desktop weaver-mobile-smart-stacked”
   doesn’t make any sens to me when “home” is the only class I need to target my
   homepage with css.
 * So that’s why I’d like to delete all unusued classes, but when a new page is 
   added by the administrator, keep the ability for WordPress to add dynamically
   page-_slug-of-the-page _.
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [6 years ago](https://wordpress.org/support/topic/body-class-cleaning/#post-12910842)
 * But you don’t know if your theme or plugins are using those classes, which they
   might be, especially the ‘not-logged-in’ one. They certainly don’t hurt anything.
   
   _I know for a fact that the Weaver theme uses the weaver classes, even in javascript._
 * And like I said, `page-` is used by WP already, so that’s not a good choice for
   your new class.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Body class cleaning’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [Joy](https://wordpress.org/support/users/joyously/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/body-class-cleaning/#post-12910842)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
