Hide Jetpack Sharing Buttons on Selected Content
Turns off Jetpack's sharing buttons on chosen post types, categories or individual posts, such as landing pages, legal pages or members-only content.
Opens WPIDE on
Code
$wpide_hide_types = array( 'page' ); // Post types.
$wpide_hide_cats = array( 'members' ); // Category slugs.
$wpide_hide_ids = array(); // Post IDs.
add_filter( 'sharing_show', function ( $show, $post ) use ( $wpide_hide_types, $wpide_hide_cats, $wpide_hide_ids ) {
if ( ! $show || ! $post instanceof WP_Post ) {
return $show;
}
if ( in_array( $post->post_type, $wpide_hide_types, true ) || in_array( (int) $post->ID, array_map( 'absint', $wpide_hide_ids ), true ) ) {
return false;
}
if ( $wpide_hide_cats && has_category( $wpide_hide_cats, $post ) ) {
return false;
}
return $show;
}, 10, 2 );
Notes
Fill in any of the three lists; leave a list empty to skip that rule.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.