Snippet: Change Author Slug with two line snippet

If you are not using WordPress as blogging platform, you probably want to change the permalink of the authors. There are few plugins that allows you to do that But I believe, some developers would want to avoid installing a plugin if a two lines of code could do the same work.

Add following snippet to your functions.php and flush your permalinks (by going to Settings->Permalinks and press the Save button). You will get 404 not found error if you do not flush your permalinks.

Snippet

add_action('init', 'cng_author_base');
function cng_author_base() {
    global $wp_rewrite;
    $author_slug = 'user'; // change slug name
    $wp_rewrite->author_base = $author_slug;
}

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>