In the tutorials requests Trello board, a user asked:
I'm styling posts differently based on what category they are in, but I'd also like to style them differently based on which author they are written by. I am adding the category name to the body class via the code I'll put in the comments. I'd like to know how to add the author name to the body or post class, as well. Thank you!
This members-only tutorial provides the code to add post author's nicename to body classes on single posts and to post classes on non-singular listing pages in WordPress.
A single post written by the user having a nicename of "sridhar":
A single post written by the user having a nicename of "usera":
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.