Quantcast
Channel: WordPress.org Forums » [Jetpack - WP Security, Backup, Speed, & Growth] Support
Viewing all articles
Browse latest Browse all 37023

Mercifull on "[Plugin: Jetpack by WordPress.com] Custom og:image for homepage not working"

$
0
0
<?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.]


Viewing all articles
Browse latest Browse all 37023

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>