Help Desk

Adding Open Graph Tags to Main Calendar Page

  • Posts: 44 Topics: 19
    | Permalink

    I would like to be able to post a link on Facebook to my main calendar page at: https://www.WomenArts.org/swandates/, but when I try to post that URL, Facebook grabs the image from one listing and the text from another. Is there a way to set the og:image and og:description tags for my main calendar page?

    When I post the individual events the featured images work correctly, and I want to be able to retain that feature.

    Thanks for your help with this.

    Martha Richards

    Posts: 11115
    | Permalink

    Hi, Martha.

    I see you’re using Yoast SEO.

    I believe that plugin has option to set the Open Graph tags for the Events custom post type archive, such as setting a dedicated image for your Events Archive page.

    Also, just a heads up that you can test your URLs at https://developers.facebook.com/tools/debug/ so you don’t have to actually put them in your Facebook feed to preview/view them.

    Please let me know how this goes for you.

    Posts: 44 Topics: 19
    | Permalink
    This reply has been marked as private.
    Posts: 11115
    | Permalink

    Here’s a snippet that may work for you:

    Please let me know how this goes for you.

    Posts: 44 Topics: 19
    | Permalink

    Dear Cliff,
    Thanks so much! This worked great for the og:image. How would I add in the og:description field.

    Martha

    Posts: 11115
    | Permalink

    I believe that should be added from Yoast SEO: wp-admin > SEO > Titles & Metas > Post Types > Events (tribe_events)

    Please let me know if you have any follow-up questions on this topic.

    Posts: 44 Topics: 19
    | Permalink
    This reply has been marked as private.
    Posts: 11115
    | Permalink

    Sorry you’re experiencing this.

    Best practice for adding custom code (like to implement a PHP snippet to modify The Events Calendar) is to create a functionality plugin, unless it’s something specific to your theme, in which case best practice is to make sure you’re using a child theme, then add the customization to your child theme’s functions.php file.

    Note that the opening <?php tag should be removed from our snippets when adding to your plugin file or your functions.php file (it’s only added to enable syntax highlighting)… unless the snippet is a complete file replacement.

    I hope this information helps!

    Posts: 44 Topics: 19
    | Permalink

    Dear Cliff,
    I found a much easier solution. I noticed that Facebook was picking up the featured image and description from the first two events on the calendar page. It took the text from the first event, but the picture on that wasn’t big enough for them, so they took the picture from the second event on the page. So I created a new event with an earlier start date, a distant end date and a big picture. Then I used Yoast to set the Facebook text and description. Sure enough, when I scraped the page, my new first event came up with the correct picture and description. Problem solved!! Yay!!

    Thanks for your help with this.
    Martha

    Posts: 11115
    | Permalink

    Facebook will guess for an image if it can’t find og:image or if the og:image file doesn’t have large enough dimensions.

    Your solution might work at this moment, but their guessing of what the image should be could change another day, and the solution I provided you would set the og:image for all event archive views, not just when sharing the https://www.womenarts.org/swandates/ URL

    Please let me know if you want to give the custom code snippet a try again — I really think that’d be the best way, and the fix might have been as easy as simply removing the leading <?php opening PHP tag in your active theme’s functions.php file.

    Posts: 7
    | Permalink

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    | Permalink

The topic ‘Adding Open Graph Tags to Main Calendar Page’ is closed to new replies.