Facebook OpenGraph for my website not returning the correct image.
-
Hi WordPress Experts!
I would like to seek your help about my problem with the FB OpenGraph. My situation is this, I successfully implemented the FB opengraph on every blog post using a funtion (which you can see below)
//Adding the Open Graph in the Language Attributes function add_opengraph_doctype( $output ) { return $output . ' xmlns:og="https://opengraphprotocol.org/schema/" xmlns:fb="https://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="100000132424794"/>'; 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="BenDaggers.Com"/>'; if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image $default_image="https://www.bendaggers.com/wp-content/themes/Lord%20of%20Avernus%20-%20Abaddon/Images/Deafult_Img.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 "\n"; } add_action( 'wp_head', 'insert_fb_in_head', 5 );
When someone Likes or shares my blog post, it returns the correct values in facebook (image, title, permalink and description).
However, if some shares my website https://www.bendaggers.com, its not returning correct image. I tried the Linter but all i get is
"Error parsing input URL, no data was scraped."
The worst part in using linter is it’s not displaying what it suppose to display like og:title, og:type, og:url and or:site_name. Just a plain error.To make my question clear, you can try to copy paste my website link in your facebook status box https://www.bendaggers.com/ and you’ll see that it’s not displaying any thumbnail.
What seems to be the problem? Need your help.
Thank you very much!
- The topic ‘Facebook OpenGraph for my website not returning the correct image.’ is closed to new replies.