Created
January 2, 2017 21:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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