I have 20 different custom roles with several users, many of whom need an author page assigned based on their role. I found here a code that seems to be useful for finding the role of the author of the post: https://wordpress.org/support/topic/custom-author-page-for-custom-role/ and I found here some code that it seems to help me to assign the page I want: Change destination author link. But combining them, in my functions.php file, doesn't work:

if ( is_author() ) {
    $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
    $role = $author->roles[0];
    if ( 'molise' === $role ) { //the name of one custom role

    add_filter( 'author_link', 'new_author_link', 10, 1 );
function new_author_link( $link ) {      
    $link = 'https://example/'; //the link where I want to point when a user click on author below the post

    return $link; //after you've set $link, return it to the filter              


any ideas? Thanks in advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.