Support » Plugin: Event Organiser » noindex past events

  • i have the shortcode set to only display future events however i just noticed whilst doing a google search for something else that it pulled up a result of an event in our database from 2015 – is there a way to inform search engines to not index past event or anything within the plugin itself? tia

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    You could do something like this in a custom plugin or theme functions.php:

    
    add_action("wp_head", function(){
    
    	if ( ! is_singular('event') ) {
    		return;
    	}
    
    	$schedule = eo_get_event_schedule(get_the_ID());
    	$now = new DateTime( 'now', eo_get_blog_timezone() );
    
    	// schedule_finish is the finish datetime of the last occurrence
    	// Or use schedule_last for the start datetime of the last occurrence
    	if ( $schedule['schedule_finish'] < $now ) {
    		wp_no_robots();
    	}
    
    });
    
Viewing 1 replies (of 1 total)
  • The topic ‘noindex past events’ is closed to new replies.