X

How To Change the Author URL Slug

Snippets by IsItWP

Are you looking for a way to change the author URL slug? This snippet will change the default slug, mysite.com/author/name, to mysite.com/profile/name. However, you can change this to anything that you would like.

Instructions:

  1. Add this code to your theme’s functions.php file or in a site-specific plugin.
  2. Change profile in line 4 to any name you would like.
add_action('init', 'cng_author_base');
function cng_author_base() {
    global $wp_rewrite;
    $author_slug = 'profile'; // change slug name
    $wp_rewrite->author_base = $author_slug;
}

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 9 Best SEO Tools to Grow Your Website Traffic, FAST!

Comments  Leave a Reply

  1. Thanks!!

  2. Thanks a bunch!!

  3. thank u

  4. thank you

  5. Remember the question from Mike Kennedy?
    How can you just have site.com/author-name/ ?

    If you set author_slug = ” ;

    this will work for the author pages but in my case I now get 404 not found errors for normal pages. It seems that an empty author slug breaks rewriting for normal pages.
    Anyone got a solution?

    1. What you may want to try is go into “permalinks” within settings and then click “save changes” to flush rewrite rules.

  6. How to change author url base on your WordPress site October 2, 2013 at 10:30 am

    […] to Kevin Chard for the cool […]

  7. I have been able to change the author_base permalink structure with code similar to the above, but I have created a custom role and I’m wondering if I could have 2 different author_base’s based upon the user role. The default structure for admins, authors, ect (/author/authorname) and another for the new user role (/gift-registry/authorname).

    Ryan

  8. Thank you!

  9. @wpsnipp:disqus is it possible to create custom author slugs based on user roles?

  10. add $wp_rewrite->flush_rules()
    at the end of the function it’ll work without 404 🙂

    1. thanks bro

  11. I placed this inside functions.php and it did change the slug, however I’m getting a 404 when I visit the new slug. Any suggestions? Thanks

    1. Hi Zach, if you continue to have problems you could try this plugin as you should not have any problems.

      http://wordpress.org/extend/plugins/author-slug/

      1. Hi Kevin,

        Thanks for the suggestion. However, I did see that plugin and would love to figure out how to use it without a plugin — I’m building a very large site and I’m trying to cut down the number of plugins.

        Thanks,
        Zach

        1.  Hi Zach you could simply take the code out of the plugin and place it within your functions.php and that will work fine.

        2. For anyone else having the same problem…just flush the permalinks(Going into Settings->permalinks flushes them)

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!