WordPress One Liner to Customize Author Permalink

Several people have asked me recently how to customize the author permalink from being /author/admin to something like /profile/admin. I have created a simple one line piece of code that you can drop in your themes functions.php to achieve this.

add_filter('init', create_function('$a', 'global $wp_rewrite; $wp_rewrite->author_base = "profile";'));

Drop this into your themes functions.php wrapped in <?php ?> tags, then visit the WordPress admin, go to Settings->Permalinks then off you go. By visiting the permalinks settings page it should flush the rewrite rules, but if for some reason it doesn’t go ahead and click “Save Changes”. If you want /author/ to become something other than /profile/ replace ‘profile’ in that one liner with the string of your choice.

About Matt

IF YOU REALLY want to hear about it, the first thing you'll probably want to know is where I was born, and what my lousy childhood was like, and how my parents were occupied and all before they had me, and all that David Copperfield kind of crap, but I don't feel like going into it, if you want to know the truth.

In any case I am employed as a Senior Linux Systems Engineer at Rackspace in San Antonio, TX.

I spent the majority of my college years as an Astrophysics major specializing in black holes. When I got to my senior year and was studying 40 hours a week to stay on track I decided to bail and pursue an easier career.

I spend the majority of my time now contributing to WordPress, developing WordPress plugins, helping out in the WordPress IRC Channel, playing football (not American!), practicing Krav Maga, and last but not least, spending time with my Wife and Son.

This entry was posted in Code, One Liner, PHP, Snippet, WordPress. Bookmark the permalink.

9 Responses to WordPress One Liner to Customize Author Permalink

  1. Pingback: Bookmarks for Sunday, January 4th — Trevor Fitzgerald

  2. Pingback: Gutes von hier und anderswo Link Love

  3. Pingback: Yazar Bağlantılarındaki Author’u Değiştiriyoruz · Yakup Gövler'in Not Defteri

  4. John says:

    When inserting this string in my functions.php I now always get the following warning when editing author information:

    Warning: Cannot modify header information - headers already sent by (output started at /home/skogsnat/public_html/wp-content/themes/mimbo/functions.php:477) in /home/skogsnat/public_html/wp-includes/pluggable.php on line 850

    Removing the string doesn’t solve anything as the page then can’t find the original author information anymore.

    Any suggestions on what to do?

    Thanks for a good line of code!

    • Matt says:

      Make sure that you wrap that code inside of <?php code here ?>

      • John says:

        I really did. But this happened anyhow. Then when I took the string away WP can’t find author info but I get 404:ed instead. I’m trying to restore this with a backup now. I’m not really a php expert… would need one sometimes though :p

  5. John says:

    It seems like the string is affecting a lot of other *.php files. For instance the feed button for each author stopped to work when the line is active. But when I remove the line I get a feed at http://mywebsite.com/profile/name/feed.

    Is that possible to explain?

  6. John says:

    Solved it now:
    I made the string active again in functions.php and just replaced the term ”profile” with the original ”author”. Saved the file. Opened the file again and removed the string. Now everything seems intact. But in my case this string caused a lot of trouble, maybe because of my theme?

  7. scribu says:

    Triggering flush_rules() on every page load is not a good ideea.

Leave a Reply

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

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre>