Advertisement
alchymyth

remove body_class filter

Jan 28th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter('body_class', 'alc_remove_body_class', 20, 2);
  2. function alc_remove_body_class($wp_classes, $extra_classes) {
  3. if( is_page_template('template-file-name.php') ) :
  4. // List of the classes to remove from the WP generated classes
  5. $remove = array('singular'); //allows for multiple classes to be removed
  6. // Filter the body classes
  7.   foreach( $remove as $val ) {
  8.     if (!in_array($val, $wp_classes)) : continue;
  9.     else:
  10.       foreach($wp_classes as $key => $value) {
  11.       if ($value == $val) unset($wp_classes[$key]);
  12.       }
  13.     endif;
  14.   }
  15. endif;   // Add the extra classes back untouched
  16. return array_merge($wp_classes, (array) $extra_classes);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement