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.

How do I prevent author archives without posts from 404ing?

share|improve this question
add comment

1 Answer

Why should you get redirected to the 404 page if you display an author archive without posts? This isn't the default behavior of WordPress.

For example, if you go to the following URL:

http://example.com/{permalink_base}/author/{author_name}

WordPress calls the author.php template inside your theme folder. There you have a loop which will return all posts of the author {author_name}. If this user has no posts, the loop will return nothing and will not redirect to the 404.php template.

So you have to options:

  1. Look in your themes author.php file what's going on there
  2. Check if the user really exists in WordPress. You have to use the username and not the display or nicename inside the URL.
share|improve this answer
    
I just downloaded a fresh install of WP and Twenty Elven theme and tested this, it still doesn't work. All authors without posts get a 404. This is a plugin for this specific function: wordpress.org/extend/plugins/show-authors-without-posts but its old and no longer works with the current WP version –  Jack Stewart Sep 25 '11 at 18:02
    
Look inside the twentyeleven folder and open the file author.php. There you can see an if-statement on line 15 which checks if the author has posts. If not (line 70) a Nothing Found snippet will be displayed. Remove the if-statement and you will get a white/blank page. –  rofflox Sep 25 '11 at 18:10
    
okay gotcha, it was the "<?php else {" that made it 404 , but my theme doesn't have that else statement, is there anywhere else that wordpress is looking besides the author template? –  Jack Stewart Sep 25 '11 at 18:27
1  
If your theme doesn't have an author.php template, the template from twentyten will be used. Copy the author.php file from twentyeleven to your theme and edit it like you want. –  rofflox Sep 25 '11 at 18:42
add comment

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.