I’d like to edit the value of twitter:site to show my Twitter handle instead of @jetpack
You can customize this value by adding the following code to your theme’s functions.php file:
function tweakjp_custom_twitter_site( $og_tags ) {
$og_tags['twitter:site'] = '@jeherve';
return $og_tags;
}
add_filter( 'jetpack_open_graph_tags', 'tweakjp_custom_twitter_site', 11 );
You’ll have to replace my twitter username with your own, of course ??
all my posts show twitter:card as photo and again I don’t see anywhere to change this.
Jetpack actually looks for images into your posts:
- If you didn’t insert any image, the twitter card will be set to “summary”
- If you insert between 1 and 4 images, the twitter card will be set to “photo”
- if you insert more than 4 images, the twitter card will be set to “gallery”
Of course, you’ll welcome to overwrite this default behaviour by adding one more line to the previous code:
function tweakjp_custom_twitter_site( $og_tags ) {
$og_tags['twitter:site'] = '@jeherve';
$og_tags['twitter:card'] = 'summary';
return $og_tags;
}
add_filter( 'jetpack_open_graph_tags', 'tweakjp_custom_twitter_site', 11 );
Another solution would be to use a different Twitter Card plugin, like JM Twitter Cards as @ab11936 mentioned. You can use both Jetpack and this plugin at the same time. As soon as you activate the plugin, Jetpack’s twitter cards will be deactivated, along with another related Jetpack feature: the Open graph cards used by Facebook. That means that you’d have to install another plugin, like WP Open Graph.