Created
October 24, 2016 17:40
-
-
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.
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_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