WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Double Titles in Google+ (og:title) (1 post)

  1. japanworm
    Member
    Posted 1 year ago #

    Hi!

    I've got a problem that is driving me crazy! I've been working on this for hours on my own now and can't get it fixed!

    I installed the Yoast SEO plugin today (replacing the All in One SEO).
    Everything works fine except when I try to share something on Google+.

    I've done a lot of research and found that I'm not the only one with that issue. I tried what was suggested in this thread.

    I disabled the open graph in Yoast.
    Nothing changed.

    I have this code in my function.php:

    //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
    		return;
            echo '<meta property="fb:admins" content="377035309011137" />';
            echo '<meta property="fb:app_id" content="235244769925765" /> ';
            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="Zooming Japan - Detailed Japan Guide"/>';
    	if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
    		$default_image="http://zoomingjapan.com/wp-content/themes/alltuts/images/linkback_600x156ver2.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 "\n";
    }
    add_action( 'wp_head', 'insert_fb_in_head', 5 );

    If I just take the line with the "og: title" out I don't get double titles in Google+ anymore, but then Facebook can't generate the proper title and description anymore!

    I also found out that with a Jetpack update open graph was enabled, so I tried turning it off by using the following code:

    add_filter( 'jetpack_enable_open_graph', '__return_false' );

    .. as it was suggested here.

    This also doesn't work.
    I'm really out of ideas. I tried every solution that was given online thus far, but none of them worked.

    For reference, this is my blog.

    I hope somebody can help me! :(

    http://wordpress.org/extend/plugins/wordpress-seo/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic