2

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

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.

  • If author does not posses any posts then what will actually be displayed on the page? I mean you can always show the authors with no posts by <?php wp_list_authors('hide_empty=0'); ?> but redirecting to an author archive page that is empty seems useless. – Borek Jan 18 '14 at 19:27
  • @Borek Why that? You could show pretty much all info entered in the (possibly extended) profile page like "Bio", contact methods, etc. – kaiser Jan 27 '15 at 14:58
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).

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.