author_link filter not work correctly

i want to change author link page.
by default it’s:
site.com/author/user_nice_name

but i want change it to:
site.com/teacher/user_nice_name

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);


Source: https://wordpress.stackexchange.com/feeds

Related posts

Leave a Comment