Posted: 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! |
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? — |
|
|
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”. |
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. |
|
|
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! |
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. |
|
|
Josh, this worked perfectly. Thank you so much for the excellent support! |
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.