php - Cancel the AddThis Wordpress plugin on certain posts -
i have wordpress site utilizes multiple custom post types achieve different goals. use addthis plugin append social sharing buttons top of posts. however, have 1 type of custom post not plugin append addthis sharing buttons to. there way hook addthis plugin return false or given condition?
maybe like:
if($post_type === "no-addthis"){ addthis_plugin_hook(false); } i totally realize that's not valid way it, know of similar? in advance.
the following remove addthis filters operating on current post:
if( get_post_type( get_the_id() ) == 'your-post-type' ) { remove_filter('the_content', 'addthis_display_social_widget', 15); remove_filter('the_content', 'addthis_script_to_content'); remove_filter('get_the_excerpt', 'addthis_display_social_widget_excerpt', 11); remove_filter('get_the_excerpt', 'addthis_late_widget', 14); remove_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 2); } i'd advise running code right before call the_content() or the_excerpt() ( or similar function prefixed get_ ) in custom post type template.
note: haven't tested , i've never used addthis plugin. peeked @ source code now. :)
Comments
Post a Comment