In WordPress terminology, a slug is a title of a publicly viewable page in WordPress formatted to be used in URLs.
My author url for this site is: https://weusewp.com/author/morshed/
Here orange colored text is the slug and green colored text is the base. That means “morshed
” is the slug and “author
” is the base. By default, WordPress uses “author” as base. You may want to change it as Thought Might did. There my author url is https://thoughtmight.com/blog/morshed/
To change the author base, copy and paste following code to your theme’s functions.php file.
function new_author_base() {
global $wp_rewrite;
$myauthor_base = 'writer';
$wp_rewrite->author_base = $myauthor_base;
}
add_action('init', 'new_author_base');
Change ‘writer‘ according to your need. That’s it. These few lines of code will change the author base all over your site.
To change the author slug, copy and paste following code to your theme’s functions.php file.
if (current_user_can('manage_options')) {
function lwp_2629_user_edit_ob_start() {ob_start();}
add_action( 'personal_options', 'lwp_2629_user_edit_ob_start' );
function lwp_2629_insert_nicename_input( $user ) {
$content = ob_get_clean();
$regex = '/<tr(.*)class="(.*)\buser-user-login-wrap\b(.*)"(.*)>([\s\S]*?)<\/tr>/';
$nicename_row = sprintf(
'<tr class="user-user-nicename-wrap"><th><label for="user_nicename">%1$s</label></th><td><input type="text" name="user_nicename" id="user_nicename" value="%2$s" class="regular-text" />' . "\n" . '<span class="description">%3$s</span></td></tr>',
esc_html__( 'Nicename' ),
esc_attr( $user->user_nicename ),
esc_html__( 'Must be unique.' )
);
echo preg_replace( $regex, '\0' . $nicename_row, $content );
}
add_action( 'show_user_profile', 'lwp_2629_insert_nicename_input' );
add_action( 'edit_user_profile', 'lwp_2629_insert_nicename_input' );
function lwp_2629_profile_update( $errors, $update, $user ) {
if ( !$update ) return;
if ( empty( $_POST['user_nicename'] ) ) {
$errors->add(
'empty_nicename',
sprintf(
'<strong>%1$s</strong>: %2$s',
esc_html__( 'Error' ),
esc_html__( 'Please enter a Nicename.' )
),
array( 'form-field' => 'user_nicename' )
);
} else {
$user->user_nicename = $_POST['user_nicename'];
}
}
add_action( 'user_profile_update_errors', 'lwp_2629_profile_update', 10, 3 );
}
From Users » All Users page, click on the ‘Edit’ link below a username. You will find a “Nicename” section. You can edit the slug here.
Click on the ‘Update User’ button after editing author slug.
References:
We Use WP dot com