Created
November 15, 2016 13:30
-
-
Save dariodev/4584eea20351eaeb3aa81682d13a0a93 to your computer and use it in GitHub Desktop.
Adding author role in body class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add role class to body | |
function add_role_to_body($classes) { | |
global $current_user; | |
$user_role = array_shift($current_user->roles); | |
// add class 'role-user_role' to the $classes array | |
$classes[] = 'role-'. $user_role; | |
return $classes; | |
} | |
add_filter('body_class','add_role_to_body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment