Title: [Plugin: AddThis] Support for Custom Post Types
Last modified: August 20, 2016

---

# [Plugin: AddThis] Support for Custom Post Types

 *  [ajuliano](https://wordpress.org/support/users/ajuliano/)
 * (@ajuliano)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/)
 * I’m using this plugin on a website with three different custom post types, but
   I only wanted the AddThis-buttons to be displayed on Posts.
 * Unfortunately this plugin doesn’t have support for hiding the buttons on Custom
   Post Types. I added two lines of code to hide it on my Custom Post Types, but
   i think it would be better to have an option on the settings-screen.
 * I added this on line 1183 in the file addthis_social_widget.php:
 *     ```
       elseif ( 'my_custom_post_type' == get_post_type() )
           	$display = false;
       ```
   
 * [http://wordpress.org/extend/plugins/addthis/](http://wordpress.org/extend/plugins/addthis/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Aaron Jorbin](https://wordpress.org/support/users/jorbin/)
 * (@jorbin)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310017)
 * Hi Ajuliano,
 * The best way to remove it from custom post types would be to use the addthis_post_exclude
   filter. You could do something along the lines of:
 *     ```
       add_filter('addthis_post_exclude', 'my_addthis_post_exclude_filter');
       function my_addthis_post_exclude_filter($display)
       {
       if ( 'my_custom_post_type' == get_post_type() )
           $display = false;
   
       return $display;
       }
       ```
   
 *  [madhavaji](https://wordpress.org/support/users/madhavaji/)
 * (@madhavaji)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310032)
 * Hey Aaron,
 * Great fix my man.. works like a charm 🙂
 * Michael.
 *  [stevemagruder](https://wordpress.org/support/users/stevemagruder/)
 * (@stevemagruder)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310062)
 * This worked for me too, thanks!
 * I’d note that in my case, the post type I had to use in this scenario was blank(”),
   as it wasn’t reported by the plugin that created the post type. I say this in
   case anyone runs into something like this.
 *  Thread Starter [ajuliano](https://wordpress.org/support/users/ajuliano/)
 * (@ajuliano)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310065)
 * Thank you Aaron!
 * Worked great for me as well.
 * Although I use `switch`, because I’ve got multiple post-types to hide it from.
 *     ```
       add_filter('addthis_post_exclude', 'my_addthis_post_exclude_filter');
       function my_addthis_post_exclude_filter( $display ) {
       	switch ( get_post_type() ) {
       		case 'my_post_type_1':
       			$display = false;
       			break;
       		case 'my_post_type_2':
       			$display = false;
       			break;
       		case 'my_post_type_3':
       			$display = false;
       			break;
       		case 'my_post_type_4':
       			$display = false;
       			break;
       	}
   
       	return $display;
       }
       ```
   
 * Do you think there’s a better way of doing it?
 *  [stevemagruder](https://wordpress.org/support/users/stevemagruder/)
 * (@stevemagruder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310066)
 * ajuliano, here’s a much simpler way:
 *     ```
       add_filter('addthis_post_exclude', 'my_addthis_post_exclude_filter');
       function my_addthis_post_exclude_filter($display)
       {
       if ( in_array(get_post_type(), array('my_post_type_1', 'my_post_type_2','my_post_type_3','my_post_type_4')) )
           $display = false;
   
       return $display;
       }
       ```
   
 *  [majakovskij](https://wordpress.org/support/users/majakovskij/)
 * (@majakovskij)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310103)
 * Thank you all for the tip!!
 *  [Agnes](https://wordpress.org/support/users/agneslesagegmailcom/)
 * (@agneslesagegmailcom)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310114)
 * I found a way to insert a custom style in my template, according to this page:
   
   [http://www.addthis.com/blog/2011/03/03/addthis-for-wordpress-plugin-version-2-0-2/#.T6Op0Os5Ld4](http://www.addthis.com/blog/2011/03/03/addthis-for-wordpress-plugin-version-2-0-2/#.T6Op0Os5Ld4)
 * I added my style as an array in the plugin file (addthis_social_widget.php)
 *     ```
       $addthis_new_styles = array(
   
           'my_style' => array( 'src' =>  '<div class="addthis_toolbox addthis_default_style addthis_" %s ><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone_share"></a><a href="http://www.addthis.com/bookmark.php?v=250&pubid=ra-4fa382503d81907c" class="addthis_button_compact">
       <a class="addthis_button_email"></a><a class="addthis_button_print"></a><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a></div>', 'img' => 'toolbox-small.png', 'name' => 'My Style', 'above' => 'hidden ', 'below' => ''
           ), // My Style
       ```
   
 * And then added the code manually in the template with my style
 * `<?php do_action('addthis_widget',get_permalink($post->ID), get_the_title($post-
   >ID), 'my_style'); ?>`

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Plugin: AddThis] Support for Custom Post Types’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/addthis_70cced.svg)
 * [WordPress Share Buttons Plugin – AddThis](https://wordpress.org/plugins/addthis/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/addthis/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/addthis/)
 * [Active Topics](https://wordpress.org/support/plugin/addthis/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/addthis/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/addthis/reviews/)

 * 7 replies
 * 6 participants
 * Last reply from: [Agnes](https://wordpress.org/support/users/agneslesagegmailcom/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-addthis-support-for-custom-post-types/#post-2310114)
 * Status: not resolved