Please help with Open Graph
-
I am ready to pull the remaining hair out of my darn head. Can’t for the life of me figure out why Facebook will not pull the featured image, or even an image from inside the post, when I share via publicize from WordPress 4.0.
I have checked and un-checked ‘insert og tags’ in Yoast SEO, tried shareaholic and even hard coded the lines into my functions.php (see below for code used).
//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=”480187318774482″/>’;
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=”Islanders Insight”/>’;
if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
$default_image=”https://www.islandersinsight.com/wp-content/uploads/2014/08/BvlnJMzIUAEGHEu.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 ), ‘large’ );
echo ‘<meta property=”og:image” content=”‘ . esc_attr( $thumbnail_src[0] ) . ‘”/>’;
}
echo “
“;
}
add_action( ‘wp_head’, ‘insert_fb_in_head’, 5 );This is the facebook page : https://www.facebook.com/IslandersInsight
And this is the post : https://www.islandersinsight.com/2014/10/new-york-islanders-vs-san-jose-sharks-pregame-report/
Can anyone please help? I am about to start trying to slash my wrists with plastic knives.
Thanks
- The topic ‘Please help with Open Graph’ is closed to new replies.