Skip to content

Instantly share code, notes, and snippets.

@tillkruss
Last active December 22, 2017 01:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tillkruss/5660075 to your computer and use it in GitHub Desktop.
Save tillkruss/5660075 to your computer and use it in GitHub Desktop.
Disable front-end blog functionality in WordPress, including categories, author archives, etc.
<?php
add_action( 'template_redirect', function() {
global $wp_query;
if ( is_home() || $wp_query->is_singular( 'post' ) || $wp_query->is_post_type_archive( 'post' ) ) {
header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );
$wp_query->set_404();
}
}, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment