Posted By

joelhaus on 10/06/09


Tagged

css class php wordpress filter thesis thesiswp


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

joelhaus
vintagekrug


Add Custom Body Class to WP Thesis


 / Published in: PHP
 

URL: http://codesnippets.joyent.com/posts/show/2304

Function to add custom body class in th Thesis theme for WordPress...Thanks to @girliegeek!

  1. // Add my-custom-class to body tag
  2.  
  3. function custom_body_class($classes) {
  4. $classes[] = 'my-custom-class';
  5. return $classes;
  6. }
  7. add_filter('thesis_body_classes', 'custom_body_class');
  8.  
  9. // To single pages only
  10.  
  11. function custom_body_class($classes) {
  12. if (is_single()) {
  13. $classes[] = 'my-custom-class';
  14. return $classes;
  15. }
  16. }
  17. add_filter('thesis_body_classes', 'custom_body_class');

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: joelhaus on November 16, 2009

An even better method using WP's native bodyclass: (via: http://diythemes.com/forums/bug-reports/17306-thesis-breaks-wp-bodyclass-function.html)

function mybodyclass( $class = '' ) { // Separates classes with a single space, collates classes for body element echo ' class="' . join( ' ', getbodyclass( $class ) ) . '"'; }

addfilter('thesisbodyclasses','mybody_class');

You need to login to post a comment.