There are a few ways, in my opinion, stopping archives from being indexed, I use the following code, it seems to work well.
This will also get rid of the annoying ‘author’ also.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* Register template redirect action callback */ add_action('template_redirect', 'codehaven_remove_wp_archives'); /* Remove archives */ function codehaven_remove_wp_archives(){ //If we are on category or tag or date or author archive if( is_category() || is_tag() || is_date() || is_author() ) { global $wp_query; $wp_query->set_404(); //set to 404 not found page } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* Register template redirect action callback */ add_action('template_redirect', 'codehaven_remove_wp_archives'); /* Remove archives */ function codehaven_remove_wp_archives(){ //If we are on category or tag or date or author archive if( is_category() || is_tag() || is_date() || is_author() ) { global $wp_query; wp_redirect( home_url( '/' ) ); // $wp_query->set_404(); //set to 404 not found page } } |