Saturday, May 28, 2022
HomeWordPress Developmentphp - Workaround for og:picture unsupported webp picture kind, Yoast website positioning?

php – Workaround for og:picture unsupported webp picture kind, Yoast website positioning?


My web site Beta Fox makes use of Yoast website positioning plugin to assist take care of website positioning frequent practices, nevertheless a problem has arisen. In starting of final 12 months WordPress did not absolutely assist webp picture varieties, neither Yoast website positioning. Issues modified close to the top of 12 months, however Yoast website positioning unbelievably refuses to assist webp (the categories Google is forcing upon on us to make use of). The issue is the actual fact there is no open graph for picture attachments in any web page of the positioning, so meaning hyperlink preview would not present any picture.

add_action('wp_head', 'add_link_prev_img');
    perform 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()) == 'picture/webp') {
        <meta property="og:picture" content material="<?php echo $fotoo;?>"> 
            }
    }

The code above was supposed so as to add the meta tag that’s lacking in pages/posts of my web site, however would not work as meant. It causes vital error within the web site. Each web page wants to point out featured picture or one thing related if out there. Please, assist!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments