Skip to content

Instantly share code, notes, and snippets.

@mourique
Created September 8, 2015 19:01
Show Gist options
  • Save mourique/920013c6bc1458fa16ec to your computer and use it in GitHub Desktop.
Save mourique/920013c6bc1458fa16ec to your computer and use it in GitHub Desktop.
/* Kill attachment, search, author, daily archive pages */
add_action('template_redirect', 'custom_template_redirect');
function custom_template_redirect(){
global $wp_query, $post;
if (is_author() || is_attachment() || is_day() || is_search() || is_category())
{
$wp_query->set_404();
}
if (is_feed())
{
$author = get_query_var('author_name');
$attachment = get_query_var('attachment');
$attachment = (empty($attachment)) ? get_query_var('attachment_id') : $attachment;
$day = get_query_var('day');
$search = get_query_var('s');
if (!empty($author) || !empty($attachment) || !empty($day) || !empty($search))
{
$wp_query->set_404();
$wp_query->is_feed = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment