author slug base

How to Change Author URL Slug and Base with or without Plugin

WordPress has permalink settings. WordPress offers you the ability to create a custom URL structure for your permalinks and archives. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A number of tags are available, and there are some examples in permalink settings.

However, there is no option for you to customize the author URL. In this article, I will show you how you can easily change the author URL slug and base in WordPress.

What is a URL Slug and URL Base?

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/

I will show you two ways to do that.

  • With Plugin
  • Without Plugin

I prefer the without plugin solution and you should too as no one should use a third party plugin if it can be done with some lines of code. See how WP User Avatar Plugin Becomes Something else leaving users frustrated.

1. With Plugin

Install and activate the Edit Author Slug plugin.

To change the author base, go to the Settings » Edit Author Slug page. Here you will see an option to change the author base and even choose different author base for users with different user roles.

change author base in WordPress

Once you are finished, click on the save changes button.

To change the author slug, go to Users » All Users page. Next, click on the ‘Edit’ link below a username.

edit user in WordPress

From Edit User screen, scroll down to ‘Edit Author Slug’ section, and you will see a number of choices that you can use as author slug. You can even enter a custom slug.

edit author slug in WordPress

Don’t forget to click on the ‘Update User’ button.

2. Without Plugin

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.

Nicename in WordPress

Click on the ‘Update User’ button after editing author slug.

Comment below to let me know if it works for you or not.

Spread the love

A teacher by profession, a traveler by passion and a netizen by choice.

Morshed Alam

You use WordPress! Why don't we share our experience! It may be a tutorial, tips, tricks or about security, performance or WordPress news. Write Today

19 thoughts on “How to Change Author URL Slug and Base with or without Plugin”

  1. This was a great help – new to WordPress functions and I was able to implement this without any issues. Thank you

  2. very useful tutorial and i am using the same code from here and everything work perfectly. i have one problem i am facing before changing my author base to profile i was using is_author function to set meta tags to no index and no follow for my author archive but when i changed my author base to profile its not working anymore can you please help i am using this code in my functions.php file to noindex my author archive.
    add_action(‘wp_head’, ‘header_function_condition_noindex_all_author’);
    function header_function_condition_noindex_all_auhtor(){
    if ( is_author() ) { ?>

    <?php }
    };

    1. Morshed Alam

      Thank you for your comment.

      If you use Yoast SEO plugin, there is a buit-in option to noindex author archive.
      Go to Yoast SEO > Search Appearance > Archives.
      Turn off “Show author archives in search results?” and save changes. See here.

      If you don’t use Yoast SEO plugin, following code will help you:

      add_action('wp_head', 'noindex_authors');
      function noindex_authors() {
      if(is_author()) {echo "<\meta name='robots' content='noindex, follow'>";}
      }

      N.B. Remove the backslash from the meta tag.

      Let me know if it works or not.

  3. thank you so much for your quick reply. i am not using any plugin at tall for SEO just learning and trying to do it manually. and definitely this is the code i needed. thank you so much!

  4. Will this work if I want the author link to redirect to our about page, without a 301? For example, I would like to have all author links in each article do the following (without using a 301): domain.com/authour/XYZ —> domain.com/about

  5. Thanks for the quick reply. I realized that after attempting, I was about to change the nicename to “about”, but I still needed to have the author in the slug (about/XYZ). So, do you know of any way to do this without a 301?

    1. Morshed Alam

      Ok. If you want to achive this, do these two things:
      1. Change the author base, not the nicename.
      2. Add following code at the end of functions.php

      add_action('template_redirect', 'authortoabout');
      function authortoabout() {
      if( is_author()) {
      wp_safe_redirect(home_url('/about/'));
      exit();
      }
      }

Leave a Comment

Your email address will not be published. Required fields are marked *