updated   : May 15, 2012
we now have 588 snippets
By : , on January 16, 2011 2:00 pm

Change the author slug, URL base

wordpress snippet

Adding this to the functions.php of your wordpress theme will change the default mysite.com/author/name to mysite.com/profile/name, however you can change this to user or anything that you would like.

snippet :  PHPcopy
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;
}
  • http://www.facebook.com/profile.php?id=718420569 Zach Levine

    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

    • http://wpsnipp.com Kevin Chard

      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/

      • http://www.facebook.com/profile.php?id=718420569 Zach Levine

        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

        • http://wpsnipp.com Kevin Chard

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

  • Nope

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