Advertisement
brook-tribe

Tribe 404 Meta=noindex Test

Apr 22nd, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. // This snippet adds diagnostic info to your sites <head> html comments
  2. // If both is_404() & tribe_is_event_query() == true, it will output a noindex meta tag
  3. // Tribe should be doing this already, but some plugins & themes strip these tags
  4. // This function further tries to avoid stripping those tags by adding 100 priority to the action
  5. add_action('wp_head', 'tribe_noindex_on_404', 100);
  6.  
  7. function tribe_noindex_on_404() {
  8.     $is_404 = is_404();
  9.     $tribe_is_event_query = tribe_is_event_query();
  10.  
  11.     $output =  '<!-- Tribe Index Test'."\n";
  12.     $output .= 'is_404(): '.($is_404 ? 'true' : 'false')."\n";
  13.     $output .= 'tribe_is_event_query(): '.($tribe_is_event_query ? 'true' : 'false')."\n";
  14.     $output .= '-->'."\n";
  15.  
  16.     if ( $is_404 && $tribe_is_event_query ) {
  17.         $output .= '<meta name="robot" content="noindex,follow" />' . "\n";
  18.     }
  19.  
  20.     echo $output;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement