Override default url for author pages?

The question:

So the default url to display a list of posts by a particular author looks like this:

http://domain.com/author/{username}

I am wondering how to change the ‘author’ in that url to something else?

I am working on a website for a charter school and they would like to allow each teacher to have a list of posts by “classroom”. So the desired url would be

http://domain.com/classroom/{username}

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

You might wish to try..
http://wordpress.org/extend/plugins/custom-author-base/

Hope that helps.. 😉

Method 2

You can add this in your functions, and it will rewrite the slug from default “author” to “classroom”,

function new_author_base() {
    global $wp_rewrite;
    $author_slug = 'classroom';
    $wp_rewrite->author_base = $author_slug;
}
add_action('init', 'new_author_base');

hope it helps you

Method 3

I use “Edit Author Slug” plugin for doing the same on my http://www.techcartnow.com/author/kapil-khandelwal/ WordPress Blog. I have modified “author slug” using this plugin.

Edit Author Slug” plugin allows you to change both the author base (the ‘/author/’ portion of the author URLs), and the author slug (defaults to the username of the author).

Method 4

You can add this in your functions.php:

global $wp_rewrite;
$wp_rewrite->author_base = "member"; // or whatever
$wp_rewrite->flush_rules();


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment