Adding Open Graph Tags to Main Calendar Page

Home Forums Calendar Products Community Events Adding Open Graph Tags to Main Calendar Page

  • This topic has 11 replies, 2 voices, and was last updated 6 years ago by Martha.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1466511
    Martha
    Participant

    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

    #1466776
    Cliff
    Member

    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.

    #1466803
    Martha
    Participant

    This reply is private.

    #1467702
    Cliff
    Member

    Here’s a snippet that may work for you:

    https://gist.github.com/cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa

    Please let me know how this goes for you.

    #1467788
    Martha
    Participant

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

    Martha

    #1467815
    Cliff
    Member

    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.

    #1467826
    Martha
    Participant

    This reply is private.

    #1467837
    Cliff
    Member

    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!

    #1467877
    Martha
    Participant

    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

    #1467890
    Cliff
    Member

    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.

    #1487139
    Support Droid
    Keymaster

    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

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Adding Open Graph Tags to Main Calendar Page’ is closed to new replies.