Home Forums Social Media Buttons Add-on Correcting open graph tags

Correcting open graph tags

Posted: July 18, 2014 at 9:29 am

Alden Robinson

July 18, 2014 at 9:29 am

I’m trying to get Open Graph tags on my event registration pages. I installed the social media add-on (I’m using Event Espresso – Version 3.9.1). It does add open graph tags to each event, but it pulls in the wrong og:image. I want to use the featured image from that particular event, but sometimes it selects featured images from other events. Is there a way I can fix this? Or is there a better way to populate OG tags?

Thank you for your help!

Lorenzo Orlando Caum

  • Support Staff

July 18, 2014 at 11:39 am

Hi Alden,

Are you running into this issue on a single event page or the event list page?

There is a FB opengraph debugger tool available. Could you share a link to the page where you are seeing this issue on?


Alden Robinson

July 21, 2014 at 10:13 am

It’s the single event page. Here’s an example:

As you can see, it’s not pulling the featured image into og:image, but rather, the last image in the feed of “upcoming shows”.


  • Support Staff

July 21, 2014 at 10:39 am

Hi Alden,

The other event list query in the sidebar under “upcoming shows” is likely reseting the query for the featured image for the event. One thing to note is normally the query for event thumbnails happens once on this page using the default EE templates.

Can you post the template code in a pastebin or github gist, then link to it here so we can investigate? The way forward here may be to make a customization to the espresso social plugin so that it ignores your custom query.

Alden Robinson

July 21, 2014 at 12:55 pm

I have a custom “registration_page_display.php” in my uploads folder. I also have a custom template in my themes folder that creates the small list. Here is a gist with both:

It’s quite possible I’m not doing this right—no expert here. I’m also not wedded to using the social plugin if there’s an easier way to just insert the tags in the header.

Thanks for your help!


  • Support Staff

July 21, 2014 at 3:05 pm

Hi Alden,

I think a simple way to work around the issue you’re seeing is to make sure that the event_meta (which is where the thumbnail URL is pulled from) is for the event that’s on the page (not any of the ones in the list).

When the social plugin generates the open graph tags, it’s kind of assuming that it only has access to the one event on the page. With the added event query, there’s a bit of a conflict now with the $event_meta global variable.

You can make sure that it generates the image url tag for this event by opening up the espresso social plugin’s espresso-social.php and looking for where it sets the $event_thumbnail_url and change it from:

if ( $event_meta && array_key_exists( 'event_thumbnail_url', $event_meta ) ) {
	$event_thumbnail_url = $event_meta['event_thumbnail_url'];
} else {
	$event_thumbnail_url = null;


$this_event_meta = event_espresso_get_event_meta($event_id);
if ( $this_event_meta && array_key_exists( 'event_thumbnail_url', $this_event_meta ) ) {
	$event_thumbnail_url = $this_event_meta['event_thumbnail_url'];
} else {
	$event_thumbnail_url = null;

The above code change removes the $event_meta global and uses a function instead so the conflict shouldn’t happen anymore.

Alden Robinson

July 23, 2014 at 11:45 am

Josh, this worked perfectly. Thank you so much for the excellent support!


  • Support Staff

July 23, 2014 at 12:09 pm

You’re welcome.

The support post ‘Correcting open graph tags’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Support forum for the Social Media Buttons add-on.
Documentation for Social Media Buttons Add-on

Status: closed

Updated by  Josh 5 years, 10 months ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!