Logged in and Logged out Body Classes

Today I wound up needing a logged-out body class on a WordPress site I’m building. Any individual who has ever coded a WordPress sites has probably included the body_class() capacity to their websites and it would look something like the following:

Well, the body_class() function permits you to effectively include classes specifically into the function like the following:

Obviously, using this logic it will add the “Logged-out” class to the body tag on every page/post/custom taxonomy page across my website. You can include other conditional functions to only show the the class name on certain types of pages such as if a post is in a certain category.

Sometimes we need to Call Different Body Classes. Like when we want to call a class only who are logged in user and who are visitor or not logged in. We can use the above code in functions.php in wordpress to execute the body classes.

Leave a Comment

Your email address will not be published. Required fields are marked *

0 Shares
Tweet
Share
Pin
Share