I have header.php body tag modified to include the body_class
<body <?php body_class(category, paged, tag, page, archive, blog, home, attachment, tag); ?>>
I also have some code added to my functions.php so that the category slug is added to the body_class
Heres the full functions.php code
<?php
if ( function_exists('register_sidebars') )
register_sidebars(3);
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes, $class) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
echo $category->cat_name . ' ';
// add category slug to the $classes array
$classes[] = 'category-'.$category->slug;
}
}
// return the $classes array
return $classes;
}
?>
This works brilliantly, a great way to be able to add news banner image to all posts of the news category for example.
Hosting the site from my pc works fine, when I allow people in to view it all is fine. When I upload it to my host I get problems
At the top of each page I get
Warning: Missing argument 2 for add_category_to_single() in /home/tonguet1/public_html/wp-content/themes/TTM/functions.php on line 6
News class="single postid-493 logged-in category category-news">
For each page the last line of the error changes to match the classes that are being generated by body_class for that page.
Any ideas?