Skip to content

Instantly share code, notes, and snippets.

@dariodev
Created November 15, 2016 13:30
Show Gist options
  • Save dariodev/4584eea20351eaeb3aa81682d13a0a93 to your computer and use it in GitHub Desktop.
Save dariodev/4584eea20351eaeb3aa81682d13a0a93 to your computer and use it in GitHub Desktop.
Adding author role in body class
<?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