Missing field eventAttendanceMode & eventStatus & offers

  • April 28, 2021
  • 0
Hire Vivek Asodariya

If the Google search console is generating the below error then you can add the below code.

Missing field “eventAttendanceMode

Missing field “eventStatus

Missing field “offers

Add below code in your (child) theme’s functions.php

 

<?php
function vivek_patel_event_schema( $data, $args, $event ) {
 	if(!isset($data->eventStatus))
		$data->eventStatus = 'EventMovedOnline';
	if(!isset($data->eventAttendanceMode))	
 		$data->eventAttendanceMode  = 'OnlineEventAttendanceMode';
		
	
	
		if(!is_object($data->offers))
		{
			$offers = array();
			//print_r($event);
			$offers['@type'] = 'offer';
			$offers['url'] = get_permalink($event->ID);
			$offers['price'] = '0';
			$offers['availability'] = 'http://schema.org/InStock';
			$offers['priceCurrency'] = 'AUD';
			$offers['validFrom'] = $data->startDate;
			$data->offers = $offers;
		}
    return $data;
}
add_filter( 'tribe_json_ld_event_object', 'vivek_patel_event_schema', 100, 3);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *