apply_filters ( 'jetpack_open_graph_tags', array $tags, array $args )

Allow the addition of additional Open Graph Meta tags, or modify the existing tags.

Source file: functions.opengraph.php

View in GitHub

Parameters

$tags

(array) Array of Open Graph Meta tags.

$args

(array) Array of image size parameters.


Changelog

Since: Jetpack 2.0.0


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 existing og: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 new og: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' );

Tutorials

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s