DPDK Architecture  ->  Wordpress (stable)

Disabling the WordPress archives

By default, WordPress keeps automatic archives of all post categories, tags, dates and authors. While these aid Google in indexing the site, they can also be accessed by visitors thus resulting in pages that may not match the design style of the site. Since these pages are sometimes unnecessary (depending on the project) they can be disabled and routed to a 404. Place the following snippet inside the functions.php file of the child theme:

function remove_wp_archives(){
  if( is_category() || is_tag() || is_date() || is_author() ) {
    global $wp_query;
    $wp_query->set_404();
  }
}

Within this code the is_ parameters can be adjusted to define which archives should be set to 404, and which should stay available.

Last modifiedFriday, January 29, 2021, 8:41:53 AM UTC
Last authorGlenn de Haan
Commit ID8c81eec