Search code examples
wordpressfacebookmetasharing

Force Facebook sharing debugger meta - Wordpress to purge cache


I searched over the web and still could not find a solution. I used Yoast SEO on my WordPress to make sure I got all the Meta codes that Facebook need. One of the articles in my website work just fine, I'm not sure if there is any difference between the two articles code wise.

the tool by iframely show the following: http://iframely.com/debug?uri=https%3A%2F%2Fwww.flyttd.com%2Fus-flight-training-part-1%2F

This is the current meta code display on the webpage:

<meta property="fb:admins" content="DqxdD4X3ZGn" />
<meta property="og:title" content="קורס טיס אזרחי בארה״ב – חלק א׳ - טוּס אֶת הַחֲלוֹם" />
<meta property="og:description" content="פריסת התשתיות המתקדמות, המרחב האווירי הפתוח לרווחה, ואינספור שדות התעופה מכל הסוגים והגדלים, הופכים את אמריקה לגן שעשועים לטייסים. רק כאן תוכלו לפגוש באותו היום ובאותו השדה מבנה של מטוסי קרב, ספינת אוויר, ומטוס קרגו של אמזון, תו״כ שאתם מנסים להנחית את הצסנה המצ׳וקמקת שלכם על המסלול הנכון. וולקם טו אמריקה!" />
<meta name="description" content="פריסת התשתיות המתקדמות, המרחב האווירי הפתוח לרווחה, ואינספור שדות התעופה מכל הסוגים והגדלים, הופכים את אמריקה לגן שעשועים לטייסים. רק כאן תוכלו לפגוש באותו היום ובאותו השדה מבנה של מטוסי קרב, ספינת אוויר, ומטוס קרגו של אמזון, תו״כ שאתם מנסים להנחית את הצסנה המצ׳וקמקת שלכם על המסלול הנכון. וולקם טו אמריקה!" /><meta property="og:type" content="article" />
<meta property="og:url" content="https://www.flyttd.com/us-flight-training-part-1/" />
<meta property="og:site_name" content="טוּס אֶת הַחֲלוֹם" />
<meta property="og:image" content="https://www.flyttd.com/wp-content/uploads/2018/12/catvot-300x162.jpg" />

Which is created by the following code in a functions.php

//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype( $output ) {
        return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
    }
add_filter('language_attributes', 'add_opengraph_doctype');

//Lets add Open Graph Meta Info

function insert_fb_in_head() {
    global $post;
    if ( !is_singular()) //if it is not a post or a page
        return;
        echo '<meta property="fb:admins" content="DqxdD4X3ZGn"/>';
        echo '<meta property="og:title" content="' . get_the_title() . ' - טוּס אֶת הַחֲלוֹם"/>';
        echo '<meta property="og:description" content="' . get_the_excerpt() . '"/>';
        echo '<meta name="description" content="' . get_the_excerpt() . '"/>';
        echo '<meta property="og:type" content="article"/>';
        echo '<meta property="og:url" content="' . get_permalink() . '"/>';
        echo '<meta property="og:site_name" content="טוּס אֶת הַחֲלוֹם"/>';
    if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
        $default_image="https://www.flyttd.com/wp-content/uploads/2018/07/mylogo.png"; //replace this with a default image on your server or an image in your media library
        echo '<meta property="og:image" content="' . $default_image . '"/>';
    }
    else{
        $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
        echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
    }
    echo "
";
}
add_action( 'wp_head', 'insert_fb_in_head', 5 );

Facebook debugger codes:

Inferred Property
The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.
Missing Properties
The following required properties are missing: og:url, og:type, og:title, og:image, og:description, fb:app_id

Solution

  • I submitted a ticket with the Facebook support team, they scrape it on their end.

    Thanks!