Invalid Events+ Schema Markup Causes Validation Errors

As can be seen in the following screenshot, Google Structured Data Testing Tool is reporting errors with the schema output of Events+.

https://static.livechatinc.com/8801096/ORAMTHQ6QS/34c43f808ba45ca5f53a48cf11306bb5/SDTT.JPG

Specifically, Location is not being properly parsed as the address.

Also, there seems to be no markup for the image field, even though E+ has a featured image. I need the image field to be populated with this featured image. Can you tell me what I would need to do to get this working?

Finally, the events I'm doing are for performers. The performers field is recommended, but there is no place in the plugin to assign this variable. Is there a way using Custom Fields and a Custom Page Template, to add this field to the schema markup so it shows in the Google Knowledge Graph?

  • James Morris

    Hello Abby,

    As discussed in chat, I've flagged this ticket for our SLS Team. If you have any further questions regarding this issue, please feel free to post them here.

    Please keep in mind that SLS Tickets deal with more complex issues and usually take a little more time than general support questions. Our team will reply back here as soon as technically possible with more information.

    Staff note: See https://premium.wpmudev.org/forums/topic/events-plus-not-spurting-out-correct-markup

    Best regards,

    James Morris

  • Panos

    Hi Abby ,

    I missed that in the previous file I shared. Could you please replace

    $content .= "<div class='wpmudevevents-location' itemprop='location' itemscope itemtype='http://schema.org/Place'>{$venue}
                <span itemprop='address' itemscope itemtype='http://schema.org/PostalAddress'>
                </span>
                </div>";

    with

    $content .= "<div class='wpmudevevents-location' itemprop='location' itemscope itemtype='http://schema.org/Place'>
                <span itemprop='name'>{$venue}</span>
                <span itemprop='address' itemscope itemtype='http://schema.org/PostalAddress'>
                </span>
                </div>";

    in the same file? It's located at line 560-561.

    I have attached it again with this change in case it is easier for you to replace files instead :slight_smile:

    Thanks!

  • Abby

    OK, so now it's got enough "correct markup" to have my events show for google, but some of the info still isn't in the right places. Here's a shot of what is going on. Again, thanks folks for being kind enough to help me with this one. Some of the information still isn't showing in the right spots, such as the venue name and address, and the featured image still isn't showing up in the image spot.... plus, the start times are wrong. Especially since this is your first impression when looking myself up, I'd love to get a handle on this :slight_smile: -
    Thanks again, Abby

  • Panos

    Hi Abby ,

    I didn't add the PostalAddress markup, cause it asks for several address fields. I have pushed this to the developer but I don't know if it will be approved.

    However you can add this markup with a custom mu-plugin to add the metaboxes to events, and by editing one file of the events plugin.

    You can download the custom mu-plugin from:
    https://gist.github.com/panoslyrakis/3ba657a9c1ff1789caf4c57d2a8f6a5c

    and upload it to wp-content/mu-plugins folder. If that folder doesn't exist you can simply create it. This should add a new metabox with some address fields that are used by the PostalAddress item:
    http://schema.org/PostalAddress

    Now can add the address info to your events. In order to display them you need to edit file:
    events-and-bookings/lib/class_eab_template.php
    and change the method method get_event_details() (about line 551) to:

    public static function get_event_details ($post) {
    		$content = '';
    		$data = Eab_Options::get_instance();
    		$event = ($post instanceof Eab_EventModel) ? $post : new Eab_EventModel($post);
    
    		$content .= '<div class="wpmudevevents-date">' . self::get_event_dates($event) . '</div>';
    
    		if ($event->has_venue()) {
    			$venue = $event->get_venue_location(Eab_EventModel::VENUE_AS_ADDRESS);
    			$address = '';
    
    			$content .= "<div class='wpmudevevents-location' itemprop='location' itemscope itemtype='http://schema.org/Place'>
                                <span itemprop='name'>{$venue}</span>";
    
                $address_data = get_post_meta( $event->_event_id, 'incsub_event_address', true );
    
                if( isset( $address_data['streetAddress'] ) && $address_data['streetAddress'] != '' ){
                    $address .= "<span itemprop='streetAddress'>{$address_data['streetAddress']}</span><br />";
                }
    
                if( isset( $address_data['addressLocality'] ) && $address_data['addressLocality'] != '' ){
                    $address .= "<span itemprop='addressLocality'>{$address_data['addressLocality']}</span><br />";
                }
    
                if( isset( $address_data['addressRegion'] ) && $address_data['addressRegion'] != '' ){
                    $address .= "<span itemprop='addressRegion'>{$address_data['addressRegion']}</span>, ";
                }
    
                if( isset( $address_data['postalCode'] ) && $address_data['postalCode'] != '' ){
                    $address .= "<span itemprop='postalCode'>{$address_data['postalCode']}</span>";
                }
    
                $content .= "<div itemprop='address' itemscope itemtype='http://schema.org/PostalAddress'>{$address}</div>";
    		}
    
    		if ($event->is_premium()) {
    			$price = $event->get_price();
    			$currency = $data->get_option('currency');
    			$amount = is_numeric($price) ? number_format($price, 2) : $price;
    			$content .= apply_filters('eab-events-event_details-price', "<div class='wpmudevevents-price'>{$currency} {$amount}</div>", $event->get_id());
    		}
    		$data = apply_filters('eab-events-after_event_details', '', $event);
    		if ($data) {
    			$content .= '<div class="wpmudevevents-additional_details">' . $data . '</div>';
    		}
    
    		return $content;
    	}

    As for adding the image you can either remove the event's Featured Image from your child theme's template file ( eg modify your single.php depending on your theme ) and then add it to the same function you modified. Or you can keep your theme's template file intact and simply add the featured image in the above mention and hide it with css like:

    $content .= "<img itemprop='image' style='display:none;' src='{$event->get_featured_image_url()}'>";

    You can add the above line after the
    $content ='';
    is set.

    Hope this helps!