Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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}

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

Hope that helps.. ;)

share|improve this answer

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

share|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
    
This is perfect. Thanks! –  Jake Jun 7 '13 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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