Hi there,
I have a template for author archive pages and I want to show a tag behind an author’s name when their role is “admin” i’ve made the tag entirely in a basic tag element but how would I add this condition?
Solved:
function get_author_role() {
// Get the author's ID
$author_id = get_the_author_meta('ID');
// Get the author's data
$author = get_userdata($author_id);
// Get the author's roles
$roles = $author->roles;
// Return the first role
return !empty($roles) ? $roles[0] : '';
}
Use dynamic data tag: {echo:get_author_role}