-
-
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.
This file contains hidden or 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' ) { | |
| 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