Add “author” to the body class of a post
-
I’m trying to find a way to add a body class “author” IF the current user is the author of the post they are viewing.
This is what I have so far…
add_filter( 'body_class','my_body_classes' ); function my_body_classes( $classes ) { if ( !$current_user->ID == $post->post_author ) { $classes[] = 'post-author'; } return $classes; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add “author” to the body class of a post’ is closed to new replies.