I was testing to see how my links appear when they are shared on WhatsApp or other social media. I found that it only shows the link, but not the meta description and page/post image etc.

I am using the latest WordPress version and Yoast SEO plugin.

How to fix it?

UPDATE: I tried some stuff hoping it will solve the problem but sadly, nothing helped: I deleted and re-installed Yoast SEO, I tried RankMath, All-in-one-seo, none of them helped. I right clicked on the page to view the source, the code looks fine and I can see the related meta in the headings but it is not applied. I mean still when I share my link, it is a simple link, no preview no nothing.

I even tried to use the code recommended by WpBeginner, that also didn't solve the problem.

I'm still looking for a way to see my links with it's preview on any soacial media.

Robots.txT and .htaccess not blocking anything.

Update2 This is the code that I use: (I have tested it with my own urls btw))

    //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
       echo '<meta property="fb:app_id" content="Your Facebook App ID" />';
        echo '<meta property="og:title" content="' . get_the_title() . '"/>';
        echo '<meta property="og:type" content="article"/>';
        echo '<meta property="og:url" content="' . get_permalink() . '"/>';
        echo '<meta property="og:site_name" content="SITE NAME"/>';
    if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
        $default_image="IMAGE ADDRESS"; //replace this with a default image on your server or an image in your media library
        echo '<meta property="og:image" content="' . $default_image . '"/>';
        $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 );
  • Are you blocking bots? What is your robots.txt? Are there any bot blocking rules in your server configuration (like .htaccess)? Dec 31, 2020 at 10:43
  • this is what i have in my robots.txt file (User-Agent: * Allow: /wp-content/uploads/ Disallow: /wp-content/plugins/ Disallow: /wp-admin/ Disallow: /readme.html Disallow: /refer/ Sitemap: example.com/post-sitemap.xml Sitemap: example.com/page-sitemap.xml ).
    – joseph
    Jan 1, 2021 at 4:45
  • and this is my .htaccess content (<IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>)
    – joseph
    Jan 1, 2021 at 4:46
  • Rather than putting your code in the comments, you should edit your question to add the code.
    – Trebor
    Jan 3, 2021 at 18:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.