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.

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.

share|improve this question

2 Answers 2

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..

share|improve this answer
    
NOTE: If you're rendering author links on the blog, obviously this will contribute toward the hits you receive on author URLs, i could expand the answer to cover unlinking author links to if that's desired, ie. convert author links to non-linked versions. –  t31os Mar 17 '11 at 11:25

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

share|improve this answer
    
I actually want blog/author/anything to 404. I don't see "author.php" in /wp-admin/theme-editor.php to edit? –  Jeff Atwood Mar 16 '11 at 2:45
    
then see the answer from t31os then again, a link to the profile of the author would also be cool instead of a 404 (for that just add a file "author.php" in the theme and maybe base it on another author.php from another theme or ask anyone here to create one.... and uhm... do not use "admin" but another name (best practice). –  edelwater Mar 16 '11 at 16:49

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.