• Resolved Pcosta88

    (@pcosta88)


    Hey All,

    I searched around the forums as well as on GitHub and I don’t see a way to add an opengraph image to a 404 page. In fact this GitHub discussion from Jono makes mention of open graph tags and nobody seems to mind the open graph image tags are missing from the 404 page (suggesting it’s not an issue)

    Even though opengraph data appears (like title) no image does. See https://pasteboard.co/oSfcD3Z13B2Z.png.

    The plugin does have a fallback image section but that’s only on posts/pages (not 404 pages).

    I also looked around for a filter that could maybe help and cannot seem to find one.

    Assuming this is expected behavior could you make a feature request to add the fallback image to 404 pages?

    Also, is there a filter that’s available to force the fallback opengraph image to appear?

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @pcosta88,

    Thanks for suggesting that feature. While drafting the FR, a question came up. Why would a 404 template page need to have og:image tag or use the fallback image? Will it be shared on social media (read FB, Instagram, LinkedIn, WhatsApp?), show up in search results or rank? What’s the rationale?

    Thread Starter Pcosta88

    (@pcosta88)

    Hey Maybellyne,

    Branding primarly. Sometimes folks inadvertingly share a URL (either automatically or manually) that’s been deleted.

    Facebook for example, will then try to grab an image off of the 404 page and usually selects some goofy one in the footer.

    It would just look better in those instances if the branding of the site via a logo would appear.

    Also consistency. You show the site title why not also show the other basic opengraph data like an image.

    Hope that helps!

    For anyone else, coming across this. I used this code and it seemed to work. Though depending on someone’s theme you may need modifications.

    function my_custom_og_image_tag(
    ) { if ( is_404() ) { echo
    '<meta property="og:image" content="UR_IMAGE_URL_HERE" class="yoast-seo-meta-tag"/> 
    <meta property="og:image:width" content="1200" class="yoast-seo-meta-tag" /> 
    <meta property="og:image:height" content="630" class="yoast-seo-meta-tag" />'; } } add_action( 'wp_head', 'my_custom_og_image_tag' );
    Plugin Support Maybellyne

    (@maybellyne)

    Thank you Pat. TIL, that never occured to me. I have created a FR.

    Thread Starter Pcosta88

    (@pcosta88)

    Thanks Mabel,

    And it’s good to hear from ya!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Open Graph Images on 404 Pages’ is closed to new replies.