“ShareThis” is a great WordPress plugin for adding social links to your Posts and pages. ShareThis plugin seamlessly enables users to share your content through Email,Facebook,Twitter, Google +1, Like, Send and many more.
This plugin works well but adds the social shortcuts to every page, post, excerpt and custom post type that you have in your WordPress website. Obviously, there are cases when you do not want it on every page. In the settings panel, there’s just option of removing it from Page and post. Given that Plugin has been downloaded nearly million times now, lack of options to exclude it from appearing on Custom posts types and from soem posts by id is surprising.
One way of removing ShareThis from unwanted Posts is to exclude those Custom Posts types like this:
Find This:
function st_add_widget($content) {
if ((is_page() && get_option('st_add_to_page') != 'no') || (!is_page() && get_option('st_add_to_content') != 'no')) {
if (!is_feed()) {
return $content.'
‘.st_makeEntries().’
‘; } } return $content; }
Replace with:
function st_add_widget($content) {
global $post;
$post_type = get_post_type( $post->ID );
$exclude_cpt = array('forum','topic','reply','static_block');
if ((is_page() && get_option('st_add_to_page') != 'no') || (!is_page() && get_option('st_add_to_content') != 'no')) {
if (!is_feed() && !in_array($post_type,$exclude_cpt)) {
return $content.'
‘.st_makeEntries().’
‘; } } return $content; }
To exclude your specific custom post type. you can define them in the $exclude_cpt = array(‘forum’,’topic’,’reply’,’static_block’);
Hope that helps.
Cheers!
Thank you very mutch!!!! I made a little modify to exclude some page ids: