some way to show the author's role in wordpress for example: Administrator, editor, author, contributor ect...

Let something like this be left:

This post was written by contributor JUan

I'm just using <? php the_author (); ?> but I can't think of anything else to show the role of the user assigned to a post

1 Answer 1


To get author role in single.php you have to get author id first. Use following code to get author id

$author_id = get_the_author_meta( 'ID' );

Then get userdata using

$user = get_user_by( 'ID', $author_id); 

or you can use

$user = get_userdata( $author_id );

now you can display role of author using :

echo implode(', ', $user_info->roles);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.