Advertisement
BakerMan

Avoid 404s on empty month views (TEC 3.0)

Jul 16th, 2013
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /**
  2.  * Let's set up a filter than transforms the status of month views from 404 (if a given
  3.  * month happens to be devoid of events) to 200.
  4.  */
  5. add_filter('status_header', 'avoid_tribe_month_view_404s');
  6.  
  7. function avoid_tribe_month_view_404s($status) {
  8.     global $wp_query;
  9.  
  10.     if ( ! isset($wp_query->query_vars['eventDisplay'])
  11.         || 'month' !== $wp_query->query_vars['eventDisplay']
  12.         || false === strpos($status, '404 Not Found') )
  13.             return $status;
  14.  
  15.     $wp_query->is_404 = false;
  16.     return str_replace('404 Not Found', '200 OK', $status);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement