Allow the addition of additional Open Graph Meta tags, or modify the existing tags.
Parameters
- $tags
array Array of Open Graph Meta tags.
- $args
array Array of image size parameters.
Changelog
- Introduced in Jetpack 2.0.0
How to use this hook
Notes
That filter allows you to completely customize the output of Jetpack’s Open Graph Meta tags.Change og:title value to be all uppercase
You could use the filter to edit an existing Open Graph Meta tag. In the example below, we’ll customize the existingog:title tag:
function jeherve_capital_title_og( $tags ) {
global $post;
if ( is_singular() && $post ) {
unset( $tags['og:title'] );
$tags['og:title'] = strtoupper( get_the_title( $post->ID ) );
}
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'jeherve_capital_title_og' );
Add a custom Open Graph image tag to your home page
Another way to use the filter would be to add a new tag. In this example, we’ll add a newog:image tag on our home page:
function jetpackme_desveloper_fb_home_image( $tags ) {
if ( is_home() || is_front_page() ) {
// Remove the default blank image added by Jetpack
unset( $tags['og:image'] );
$fb_home_img = 'YOUR_IMAGE_URL';
$tags['og:image'] = esc_url( $fb_home_img );
}
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'jetpackme_desveloper_fb_home_image' );