Help! wp book plugin messed up my featured image showing for facebook shares.
-
I’m really confused about what was changed or added by the wp book plugin. Yesterday I finally figured out how to get facebook to show the image I set as featured image when a link is shared from my blog. I added the following code to my templates functions.php
function insert_image_src_rel_in_head() { global $post; if ( !is_singular()) //if it is not a post or a page return; if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image $default_image="https://wickedgoodsavings.com/wp-content/uploads/2015/04/header2.jpg"; //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_image_src_rel_in_head', 5 );
It was working great until i installed wp book and made a facebook app for my site per wp book plugin instructions. I got about halfway through the setup for the plugin before a noticed there was this issue with the facebook images.
I uninstalled the plugin and deleted the facebook app, but it did not resolve the issue. Using the facebook debugger tool, It’s saying “fb:app_id hasn’t been included in the meta tags. Specify the app ID so that stories shared to Facebook will be properly attributed to the app. Alternatively, app_id can be set in url when open the share dialog. Otherwise, the default app id( 966242223397117 ) will be assigned.”
It pulls the featured image as og:image, but then shows the default image when it is shared.
What can i do to fix this?
Urls I’m having this problem with:
this post
and this one
- The topic ‘Help! wp book plugin messed up my featured image showing for facebook shares.’ is closed to new replies.