apply_filters ( 'sharing_title', string $post->post_title, int $post_id, int $this->id )

Filter the sharing title.

Source file: modules/sharedaddy/sharing-sources.php

View in GitHub



(string) Post Title.


(int) Post ID.


(int) Sharing ID.


Since: Jetpack 2.8.0


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 ) ) {
        } 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 );

Have a note to contribute?

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

You are commenting using your 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