filter

sharing_title

Filter the sharing title.

Parameters

$post->post_title
string

Post Title.

$post_id
int

Post ID.

$this->id
int

Sharing ID.

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

You can use that filter to customize the output of some of the sharing buttons. In the example below, we’ll use sharing_title to automatically add hashtags to the twitter sharing button, based on the tags added to the post:
function jeherve_custom_sharing_title() {
        $post = get_post();
        if ( empty( $post ) ) {
                return;
        } else {
                // Create sharing title
                $sharing_title = get_the_title( $post->ID );
 
                // Get the tags
                $post_tags = get_the_tags( $post->ID );
                if ( ! empty( $post_tags ) ) {
                        // Create list of tags with hashtags in front of them
                        $hash_tags = '';
                        foreach( $post_tags as $tag ) {
                                $hash_tags .= ' #' . $tag->name;
                        }
                        // Add tags to the title
                        $sharing_title .= $hash_tags;
                }
 
                return $sharing_title;
        }
}
add_filter( 'sharing_title', 'jeherve_custom_sharing_title', 10, 3 );