I'm trying to add a custom body class to WordPress which should be the author of the post which is displayed. I looked at different how to's and tried to create some code but it doesn't work:
add_filter( 'body_class' , 'ft_add_guest_body_class' );
function ft_add_guest_body_class( $classes ) {
// add 'wp_admin' to the $classes array
if (get_the_author() != 'MrX')
$classes[] = 'wp_admin';
// return the $classes array
return $classes;
}
The problem is that the wp_admin
body class is displayed on every page and post. When I remove the conditional the body class is still applied so it must be that.
get_the_author()
return?