WordPress.org

Support

Support » Plugins and Hacks » Jetpack by WordPress.com » [Resolved] Custom og:image for homepage not working

[Resolved] Custom og:image for homepage not working

Viewing 3 replies - 1 through 3 (of 3 total)
  • I added in the code for the custom Twitter tag which did work but the custom image did not.

    <?php
    /*
    Plugin Name: Matts OG:image fallback
    Plugin URI: http://www.frome.fm
    Description: Functionality plugin to add default open graph image to homepage when no featured image found. Also adds @FromeFM to a Twitter meta tag. Requires Jetpack. Code from http://jetpack.me/tag/open-graph/
    Version: 0.4
    Author: Matt Sims, Automattic
    Author URI: http://www.mattsims.com http://www.jetpack.me
    */
    
    function fb_home_image( $tags ) {
        if ( is_home() ) {
            // Remove the default blank image added by Jetpack
            unset( $tags['og:image'] );
    
            $fb_home_img = 'http://frome.fm/wp-content/uploads/2013/02/Vote-FFM-slider.jpg';
            $tags['og:image'] = esc_url( $fb_home_img );
        }
        return $tags;
    add_filter( 'jetpack_open_graph_tags', 'fb_home_image' );
    }
    
    function tweakjp_custom_twitter_site( $og_tags ) {
    	$og_tags['twitter:site'] = '@FromeFM';
    	return $og_tags;
    }
    add_filter( 'jetpack_open_graph_tags', 'tweakjp_custom_twitter_site', 11 );
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Resolved. Was a simple case of a misplaced }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Custom og:image for homepage not working’ is closed to new replies.
Skip to toolbar