-
-
Save stormwarning/9924909 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ------------------------------------------------------------------------------ | |
* FILTER JETPACK OPEN GRAPH TAGS ADDITIONAL TWITTER CARD SUPPORT, FACEBOOK PUBLISHER, AND OG:META FIXES | |
* For the WordPress VIP environment. | |
* @see https://dev.twitter.com/docs/cards | |
* @see https://developers.facebook.com/blog/post/2013/06/19/platform-updates--new-open-graph-tags-for-media-publishers-and-more/ | |
* ---------------------------------------------------------------------------- */ | |
add_filter( 'jetpack_open_graph_tags', function( $tags ){ | |
// TWITTER FIXES: | |
// wpcom defaults to the 'photo' card type for all posts but it should be 'summary' or not used at all ('summary' is default if no card type is specified.) | |
if( is_single() && $tags['twitter:card' ] === 'photo' ) | |
unset( $tags['twitter:card' ] ); | |
// wpcom sets card author to @wordpresscom, you should set it to your site's twitter handle ( or the author's handle. ) | |
if( is_single() ) | |
$tags['twitter:creator']= sprintf( '@%s', YOUR_TWITTER_HANDLE ); | |
// OG META FIXES | |
// Jetpack doesn't provide a description for the homepage so use the blog's description | |
// Jetpack uses 'article' for the site's home and 'website' is more appropriate. | |
if( is_home() ){ | |
$tags['og:description'] = esc_attr( get_bloginfo( 'description' ) ); | |
$tags['og:type'] = 'website'; | |
} | |
// FACEBOOK ARTICLE PUBLISHER TAG SUPPORT | |
if( is_single() ) | |
$tags['article:publisher'] = 'https://www.facebook.com/YOUR_FACEBOOK_PAGE'; | |
// return the modified open graph tags | |
return $tags; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment