author_link filter not work correctly

i want to change author link page.
by default it’s:

but i want change it to:

i used this code and it worked, but when i click on the user link i get 404 error.

function custom_author_link($link, $author_id, $author_nicename) {
    $author_nicename = get_the_author_meta( 'user_nicename' );
    $link = home_url( user_trailingslashit( 'teacher' ) ) . $author_nicename;
    return $link;

add_filter('author_link', 'custom_author_link', 10, 3);


Related posts

Leave a Comment