Using the AddThis WordPress Plugin with Custom Post Types
AddThis is super handy free service that allows you to integrate sharing tools on your website, allowing you to spread content, and drive social traffic.
That’s pretty much what they say on their website anyway, and I have to agree. The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with over 330 popular services.
The main purpose of AddThis is to make it easier for you to add the pretty little social buttons on your website or blog. Sure, you can add each separately yourself, which may give you more control (hooray!), but it will also take more of your time (clients say “boo!”).
There is a very easy to use WordPress plugin on offer (appropriately named AddThis), and it’s pretty good. Once activated it automagically inserts lines of social bookmarking buttons (Facebook Like, Google +1, Twitter etc.) at the top and/or bottom of your content in various styling options. There’s a nice administration area that appears in your Admin area under the Settings menu where you can fiddle with settings and what-not, but problem is (as I recently found out) it doesn’t play that well with Custom Post Types. You can play with the options to hide/show it for categories, the homepage, excerpts etc., however there’s no simple way to turn AddThis button sets on/off for different Post Types. It’s all or nothing.
The solution
Fortunately there is a solution, and it comes by way of the ‘addthis_post_exclude‘ filter. You can interact with the filter in your functions.php file and hey presto!
The following example allows you to turn off AddThis for Custom Post Types, but there are many other uses of course.
<?php //Exclude AddThis widgets from anything other than posts add_filter('addthis_post_exclude', 'addthis_post_exclude'); function addthis_post_exclude($display) { if ( !is_singular( 'post' ) ) $display = false; return $display; } ?>
Updated:
4 response to Using the AddThis WordPress Plugin with Custom Post Types