Skip to content

Instantly share code, notes, and snippets.

@remkus
Created October 3, 2012 13:50
Show Gist options
  • Select an option

  • Save remkus/3827005 to your computer and use it in GitHub Desktop.

Select an option

Save remkus/3827005 to your computer and use it in GitHub Desktop.
Add category to bodyclass
<?php
add_filter( 'body_class', 'fst_category_id_class' );
/**
* This function add the category name to the bodyclass.
*
* @access public
* @author Remkus de Vries
* @param mixed $classes
* @return void
*/
function fst_category_id_class( $classes ) {
global $post;
foreach( ( get_the_category( $post->ID ) ) as $category )
$classes[] = $category->category_nicename;
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment