[NSFW] How to add og:image tag to head of every page?
-
Hi,
Due to issues regarding support of webp images in Yoast SEO plugin, opengraph for those types of images is absent. And as everyone can imagine there’s no link preview image, for example my homepage [ redundant link removed ] doesn’t preview any link image. They don’t seem interested in fixing the issue, I need that every page shows og:image tag if the featured image is available.
add_action('wp_head', 'add_link_prev_img'); function add_link_prev_img () { $attachment_id = get_post_thumbnail_id( $post_id ); $image_attributes = wp_get_attachment_image_src( $attachment_id, "full" ); $fotoo = $image_attributes[0]; if (!empty($fotoo) && get_post_mime_type( get_post_thumbnail_id()) == 'image/webp') { <meta property="og:image" content="<?php echo $fotoo;?>"> } }
The code above creates critical error in the website. It should generate og:image in every page in head section. How can I correctly generate image opengraph for every page that has feature image or something similar?
The page I need help with: [log in to see the link]
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘[NSFW] How to add og:image tag to head of every page?’ is closed to new replies.