Blocking author paging for blog entries?

I’ve noticed on our WordPress blog that I get Google hits on two forms of blog entries:

http://blog.stackoverflow.com/2011/01/twitter-question-feeds-for-stack-exchange/

and

http://blog.stackoverflow.com/author/admin/page/4/

The latter form, paginating by author, is definitely not wanted.

How can I block paging by author in WordPress? I do know how to block it in robots.txt (which I will do!) but I would prefer to turn off author paging entirely, if possible.

Solutions Collecting From Web of "Blocking author paging for blog entries?"

You can send any request for author pages to a 404 with a simple action on parse_query.

add_action( 'parse_query', '_404_author_archives' );
function _404_author_archives( $qr ) {
    if( is_author() )
        $qr->set_404();
}

That should send any requests for an author page to a 404.

If you wanted to go a bit further and remove the author rewrite rules you could also do that quite easily with a filter on author_rewrite_rules.

add_filter( 'author_rewrite_rules', 'remove_author_rules' );
function remove_author_rules() {
    return array();
}

Untested, but you’ll have to let me know if that’s not quite enough author elimination..

I don’t know precisely if you say “block paging by author” if you want to:

  • do not show any posts of the author
  • show all posts on one page

Anyway, WordPress follows a template hierarchy: http://codex.wordpress.org/Template_Hierarchy

Meaning: if there is a file named “author.php” in your /wp-content/theme/yourtheme folder then that file can be edited to display anything you want.

Inside that file you find “the loop” : http://codex.wordpress.org/The_Loop (under the the part were the author info is).

If you do not want to show any posts at all you can e.g. comment out the loop