How to always rewrite author archive page URL even if the author does not have a post

My understanding about author archive page URL rewriting is that as long as the author has atleast one post/page the URL for the archive page ofthe author will be re-written to:

http://mysite.com/author/%authorname%

However, if the author does not have any post/page then the URL for the archive page will be of the form

Read More
http://mysite.com/?author=id

How can we force wordpress to always rewrite the URL to /author-base/%author% even if the author does not possess any post/page.

Related posts

1 comment

  1. We managed this by hijacking the default author template and setting up our own.

    Set up a new url rewrite for team members:

    add_action('init', function () {
        global $wp_rewrite;
        $wp_rewrite->author_base = 'team';
        $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
    });
    

    In the template we then use:

    $uid = get_query_var('author');
    

    to get the user’s id.

    From there you can build out your own template (author.php) for your authors.

    We approached this from the perspective of wanting a custom template and url structure for our authors, but ended up solving your problem in the process (I think).

Comments are closed.