WordPress, by default, redirects you to the error page when you try to visit a category or an author without posts. This is acceptable in a lot of cases. However, in some cases, you might want to display them anyhow. Maybe you can show just the author profile with a message that the author has not authored any posts yet. I have not been able to find a non-hack solution to this yet, so here is the hack.
The 404 or the error page is issued by the method
handle_404() of class
wp-includes/classes.php file. If certain conditions are met, it does not redirect. All we need to do is add our conditions to that. We can do this by adding
!is_category() for category and
!is_author for author. So the entire
if statement looks like:
if ( (0 == count($wp_query->posts)) && !is_category() && !is_author() && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && ( false === strpos($_SERVER['REQUEST_URI'], '?'))) ) )
Now your template files for category and author will be executed even if they do not have any posts.
This is a hack, which I am not very fond of. I have used it in the Complete Wellbeing web site to handle profiles of multiple authors. But I will be looking for a better solution. I wonder if the redirection to the error page can be given to the individual templates. Also if more hooks can be added into WordPress so that certain parts of the template hierarchy are modifiable through plugins.