Skip to content

Static Social Sharing

Ben Gillbanks edited this page Sep 4, 2019 · 4 revisions

Add social sharing buttons that use static sharing urls.

This:

  1. Keeps your site fast by not including slow javascript from social networks.
  2. Keeps your site private by not adding 3rd party tracking scripts.

Filter: toolbelt_social_sharing_post_types

By default the social sharing will display on blog posts and, if the module is enabled, portfolio posts. You can change this with a filter.

Display social sharing on all single post types

function my_social_sharing_post_types() {
	return '';
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );

Display social sharing on posts and pages

function my_social_sharing_post_types() {
	return array( 'post', 'page' );
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );

Display on your own post type

function my_social_sharing_post_types( $types ) {
        $types[] = 'my-post-type';
	return $types;
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );

Filter: toolbelt_display_social_sharing

This filter runs after the post types have been filtered out. You can use this to hide the sharing options on specific posts, or older content, or whatever you can think of.

function my_display_social_sharing() {
    // Hide for post id 4.
    if ( 4 === (int) get_the_ID() ) {
        return false;
    }
    // Show for all other posts.
    return true;
}
add_filter( 'toolbelt_display_social_sharing', 'my_display_social_sharing' );

Networks

By default the plugin adds support for Facebook, Twitter, LinkedIn, Whatsapp, and Pinterest.

You can’t perform that action at this time.