Disable Shared Counts on certain categories

The Shared Counts plugin lets you specify where in a post the share buttons appear (before and/or after content). You can also exclude them on a specific post using the metabox when editing that post.

For even more control, you can use the locations filter to move or remove the share buttons programmatically. The code below removes the share buttons from any post in the “sponsored” category.

* Remove Shared Counts from sponsored posts
* @see
* @author Bill Erickson
function be_remove_shared_counts_from_sponsored_posts( $locations ) {
if( is_single() && has_category( 'sponsored' ) ) {
$locations['before']['hook'] = false;
$locations['before']['filter'] = false;
$locations['after']['hook'] = false;
$locations['after']['filter'] = false;
return $locations;
add_filter( 'shared_counts_theme_locations', 'be_remove_shared_counts_from_sponsored_posts' );
view raw functions.php hosted with ❤ by GitHub

Shared Counts