Last active
October 25, 2024 11:09
-
-
Save vielhuber/b18c26319b04052f27d0e6a74a69cbe3 to your computer and use it in GitHub Desktop.
disable category / tag / date / author / archive pages / attachments #wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function disable_uneeded_archives() { | |
if( is_category() || is_tag() || is_date() || is_author() || is_attachment() ) { | |
header("Status: 404 Not Found"); | |
global $wp_query; | |
$wp_query->set_404(); | |
status_header(404); | |
nocache_headers(); | |
} | |
} | |
add_action('template_redirect', 'disable_uneeded_archives'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment