Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Forked from joshfeck/robots_expired.php
Last active June 12, 2025 18:28
Show Gist options
  • Select an option

  • Save Pebblo/f879648b978bfcebf2acb23d27c4e243 to your computer and use it in GitHub Desktop.

Select an option

Save Pebblo/f879648b978bfcebf2acb23d27c4e243 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' ) {
echo '<meta name="robots" content="noindex">';
}
}
}
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