New Landing How can we help? Themeforest Theme Support Neighborhood Product Facebook Share Random Mess

Viewing 6 posts - 1 through 6 (of 6 total)
  • #24157
    zenessex
    Member

    How can I change the information that is shared via the facebook share button on individual product pages as the information is random nonsense and does not reflect the current product..also the correct image is not available as images are taken from related products? See attachment .

    #24370
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    Try to put this in functions.php

    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="YOUR USER 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="Your Site NAME Goes HERE"/>';
    	if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
    		$default_image="http://example.com/image.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_fb_in_head', 5 );

    Put a default image url by replacing this: http://example.com/image.jpg

    Let me know, what you got.

    Thanks,
    laranz.

    #24538
    mesheen
    Member
    Post count: 2

    Hi thanks for your help and reply, it seems a bit better for most of the time the correct image shows..but it is still not capturing the product description..any ideas..I tried adding the og:description meta but still got the same garbled description…it must be reading first from somewhere else..

    #24836
    Melanie – SUPPORT
    Member
    Post count: 11032

    Hey, there are some plugins out there which can control what is shared on facebook, maybe you can test those if one suits your needs? 🙂

    #25175
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    Try to add it in the else part, also as Melanie said, try some plugins that is easy.

    Let me know, What you got.

    Thanks,
    laranz.

    #25889
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hey guys,

    Just to let you know that I tested out the following plugin today and it worked a treat – http://wordpress.org/plugins/nextgen-facebook/

    – Ed

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register