Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created January 2, 2017 21:08
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/85dcc9947b8f406093498464f542e990 to your computer and use it in GitHub Desktop.
Save joshfeck/85dcc9947b8f406093498464f542e990 to your computer and use it in GitHub Desktop.
Exclude expired Event Espresso events from WP SEO (Yoast) plugin's XML Sitemaps
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_seo_xml_sitemap_no_expired_events( $url, $type, $post ) {
if ('espresso_events' == get_post_type( $post ) ){
$id = $post->ID;
$event = EEH_Event_View::get_event( $id );
$status = $event instanceof EE_Event ? $event->get_active_status() : '';
if ( $status == 'DTE' ) {
$url = '';
}
}
return $url;
}
add_filter( 'wpseo_sitemap_entry', 'ee_seo_xml_sitemap_no_expired_events', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment