Yoast SEO
[Plugin: WordPress SEO by Yoast] Default image for Open Graph breaks when Facebook plugin activated (5 posts)

  1. Tran Ngoc Tuan Anh
    Posted 3 years ago #


    In the latest version of WordPress SEO plugin, I see Yoast uses a filter fb_meta_tags to change the open graph meta tags. It works nicely, except one thing: the default image set in the plugin settings page doesn't work, because Facebook will get only the thumbnail image.

    I made a quick fix for this, and applied in one of my site, it's working. Here it is:

    add_filter( 'fb_meta_tags', 'bc_fb_image' );
     * Add default image open graph meta when both Facebook & WordPress SEO plugins activated
     * @param array $meta_tags
     * @return array
    function bc_fb_image( $meta_tags )
    	if ( !empty( $meta_tags['http://ogp.me/ns#image'] ) )
    		return $meta_tags;
    	$wpseo_option = get_option( 'wpseo_social' );
    	if ( empty( $wpseo_option['og_default_image'] ) )
    		return $meta_tags;
    	$image = array( 'url' => $wpseo_option['og_default_image'] );
    	$meta_tags['http://ogp.me/ns#image'] = array( $image );
    	return $meta_tags;

    I hope Yoast can include this feature in the next version of the plugin, because I see the WordPress SEO has more options for OG image (featured image, first image in the content, and the default image) than the Facebook plugin.


  2. mystus
    Posted 3 years ago #

    I'm experiencing a very similar problem - Where exactly did you put this code of yours?

  3. Tran Ngoc Tuan Anh
    Posted 3 years ago #

    In my functions.php of the theme.

  4. Pepperbase
    Posted 2 years ago #

    @rilwis Thanks for the example of the fb_meta_tags filter. Had to do some customization and got it working now.

  5. lucasrcosta
    Posted 2 years ago #

    Any news on this?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic