Advertisement
MrPauloeN

Kill attachment, search, author, daily archive pages etc.

Nov 1st, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /* Kill attachment, search, author, daily archive pages */
  2. add_action('template_redirect', 'bwp_template_redirect');
  3. function bwp_template_redirect()
  4. {
  5.     global $wp_query, $post;
  6.  
  7.     if ( is_attachment() || is_month() || is_year() || is_day())
  8.     {
  9.         $wp_query->set_404();
  10.     }
  11.  
  12.     if (is_feed())
  13.     {
  14.        
  15.         $attachment = get_query_var('attachment');
  16.         $attachment = (empty($attachment)) ? get_query_var('attachment_id') : $attachment;
  17.         $day        = get_query_var('day');
  18.        
  19.  
  20.         if (!empty($attachment) || !empty($day) )
  21.         {
  22.             $wp_query->set_404();
  23.             $wp_query->is_feed = false;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement