Support

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 – 3.1.36.5.P 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?


Lorenzo


Alden Robinson

July 21, 2014 at 10:13 am

It’s the single event page. Here’s an example: https://onelongfellowsquare.com/event-registration/?ee=8

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”.


Josh

  • 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: https://gist.github.com/aldenrobinson/2fce0cc05307503c8285

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!


Josh

  • 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;
}

to:

$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!


Josh

  • 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
http://eventespresso.com/wiki/social-media-buttons-add-on/

Status: closed

Updated by  Josh 5 years, 3 months ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.