Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created October 24, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/70979dc12f93ab25dd668ed4500be477 to your computer and use it in GitHub Desktop.
Save joshfeck/70979dc12f93ab25dd668ed4500be477 to your computer and use it in GitHub Desktop.
Add a noindex meta tag to expired Event Espresso 4 events. Useful for SEO.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_add_tagseo_meta() {
if ('espresso_events' == get_post_type() && is_single() ){
$id = get_the_id();
$event = EEH_Event_View::get_event( $id );
$status = $event instanceof EE_Event ? $event->get_active_status() : '';
if ( $status == 'DTE' ) {
?>
<meta name="robots" content="noindex">
<?php
}
}
}
add_action( 'wp_head', 'ee_add_tagseo_meta', 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment