Force og:image on Custom Taxonomy Page

#784302
  • Resolved April Mucci
    Rank Math free

    Hi – this is my 4th support ticket on this topic, hoping to finally get this issue resolved.

    1) I have a directory plugin that creates custom taxonomies for category pages
    2) I set up RankMath to be able to set the SEO Controls for each category/custom taxonomy (WordPress Dashboard > Rank Math > Titles & Meta > [custom taxonomy] and enabled the “Add SEO Controls” option)
    3) For each category, I am selecting an image using the RankMath Social Box just like I do on regular posts

    Unfortunately the source code is showing the sitewide image for og:image. I need it to use the photo I select via RankMath. This works on regular pages/posts (it shows the image I select using the RankMath box) but does not work on custom taxonomies like directory categories.

    TROUBLESHOOTING: When I use my current theme (Astra Pro) it doesn’t use the photo I’ve selected. When I switch to a different theme (Twenty Twenty Two) it works as it should and pulls the correct og:image for the custom taxonomy page. This leads me to believe it could be a conflict with the theme?

    I have 300 directory categories / website pages where this is an issue – if I try to share any of them on social, it shows a generic website image instead of the assigned photo. Unfortunately if I can’t get this resolved I’ll have to switch back to Yoast which would make me very sad, I like RankMath much better.

    Here are sample pages from my two directories:

    https://lakelandmom.com/guide/bowling-birthday-party/
    https://lakelandmom.com/summer-camps/art-craft-camps/

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    I apologize for the inconvenience you are facing with setting up the og:image for custom taxonomy pages in Rank Math. To ensure that the correct image is displayed when sharing custom taxonomy pages on social media, you can follow these steps:

    1. Check Theme Compatibility: As you mentioned, there might be a conflict with your current theme (Astra Pro). Some themes handle Open Graph tags differently. If switching to a different theme (Twenty Twenty Two) resolves the issue, you may need to reach out to the theme developer or customize the theme to ensure compatibility with Rank Math.

    2. Verify Rank Math Settings: Double-check that you have correctly set up the SEO Controls for each category/custom taxonomy in Rank Math. Ensure that you have selected the desired image using the Rank Math Social Box for each category.

    3. Use Filters: You can use filters provided by Rank Math to override the default behavior and force the og:image tag on custom taxonomy pages. Here is an example of a filter you can use:

    // Force og:image on custom taxonomy pages
    add_filter( 'rank_math/opengraph/facebook/image', function( $image ) {
        // Add your custom logic here to return the desired image URL
        return $image;
    });

    By implementing this filter in your theme’s functions.php file or a custom plugin, you can specify the image URL that should be used as og:image for custom taxonomy pages.

    If you encounter any difficulties while implementing the filter or need further assistance, please feel free to reply to this ticket, and our support team will assist you promptly.

    Thank you for your patience and for choosing Rank Math.

    Sources:
    Open Graph Meta Tags » Rank Math
    General Tab in Meta Box of Rank Math SEO Plugin
    Open Graph/Social Preview Image Is Not Displayed » Rank Math
    How to Fix the ‘og: image’ Property Should Be Explicitly Provided » Rank Math

    Hello,

    Thank you for contacting support.

    The issue is that with the set of plugins and theme, you are using the function get_queried_object_id() from WordPress which should return the ID of this category, it’s returning a different one, from the following page

    
    https://lakelandmom.com/directory/categories/
    

    This is an issue with either the directory plugin you are using or the theme modifying the WP_Query on those pages.

    Unless the pages report the correct ID we cannot set the correct og:image because it’s not being associated correctly with the information in the database.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘Force og:image on Custom Taxonomy Page’ is closed to new replies.