14

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}

6

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

Hope that helps.. ;)

| improve this answer | |
  • in that case, is there a way to list all authors under http://domain.com/classroom url? – Pmpr Jan 8 '18 at 16:51
16

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

| improve this answer | |
  • 1
    flush_rules() is quite expensive (in resources), so I would not call it on every page load. If you only do this for one site you can leave it out and just visit the Permalinks page, this will flush the rules too. – Jan Fabry Dec 27 '10 at 19:23
  • Yes @Jan Fabry, you are right, i have edit the answer now. I wrote a better solution. – Philip Dec 27 '10 at 22:34
  • 4
    For anyone wondering whether to use this snippet or the plugin t31os mentioned: the plugin does exactly the same, but with an interface to change the URL part. Since you probably won't change it every month, this snippet in your functions.php is more than enough (and won't be disabled by accident). – Jan Fabry Dec 28 '10 at 7:51
1

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).

| improve this answer | |
0

You can add this in your functions.php:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.