For the website: http://sait.nu we have share buttons on every page/post. Only Facebook won’t grab the right open graph tags.

We have tried allot to get it right but it won’t seem to work.

  • We’ve disabled all plugins but no change at all. Also switching them
    on 1 by 1 didn’t change anything at all.
  • We’ve tried different themes but no change there.
  • We’ve tried to manually add them through php:

    function fb_opengraph() {
        global $post;
    
    
    if(is_single()) {
        if(has_post_thumbnail($post->ID)) {
            $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium');
        } else {
            $img_src = get_stylesheet_directory_uri() . '/wp-content/uploads/2016/11/Uitgelichte-foto-SAIT-Home.png';
        }
        if($excerpt = $post->post_excerpt) {
            $excerpt = strip_tags($post->post_excerpt);
            $excerpt = str_replace("", "'", $excerpt);
        } else {
            $excerpt = get_bloginfo('description');
        }
        ?>
    
    <meta property="og:title" content="<?php echo the_title(); ?>"/>
    <meta property="og:description" content="<?php echo $excerpt; ?>"/>
    <meta property="og:type" content="article"/>
    <meta property="og:url" content="<?php echo the_permalink(); ?>"/>
    <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
    <meta property="og:image" content="<?php echo $img_src; ?>"/>
    

The metatags are shown correctly in the head tags through inspecting but Facebook is still not showing the right information upons sharing.

Facebook debugger:
https://developers.facebook.com/tools/debug/sharing/?q=sait.nu

Hope you can spot something we miss! Thanks in advance.

Read more here: Facebook open graph tags WordPress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: