During WordPress works sometimes we face few unwanted issues like some plugin has filters that works for all post types that actually bothers. In my short tutorial i would like to show how you can remove those filters from your custom post type very easily by a single piece of code and i believe you gonna love it.
To remove one specific filter(hook) you must have to know the actual filter name. So here is the code that you need to place in your functions.php file :
function wphats_remove_plugin_filters() { global $post; if ( 'custom_post_type_name' == $post->post_type ) remove_filter( 'the_content', 'plugin_filter_name' ); } add_action( 'wp', 'wphats_remove_plugin_filters' );
That’s cool, right ?
But if you like to remove all filters/hooks from a custom post type then just place this code in your funcitons.php file :
function wphats_remove_plugin_filters() { global $post; if ( 'custom_post_type_name' == $post->post_type ) remove_all_filters( 'the_content', 'plugin_filter_name' ); } add_action( 'wp', 'wphats_remove_plugin_filters' );
Please remember, remove_all_filters
function removes all of the hooks from filter, and remove_filter remove specific hook name. So if you use ‘remove_all_filters’ you may need to add filter for shortcode
function wphats_remove_plugin_filters() { global $post; if ( 'custom_post_type_name' == $post->post_type ) remove_all_filters( 'the_content', 'plugin_filter_name' ); /* if you want to add shortcode again */ add_filter("the_content", "do_shortcode"); } add_action( 'wp', 'wphats_remove_plugin_filters' );
That’s all. Still if you any question. Please drop a message below.
Thanks.
This post has already been read 8108 times!
What is Lead Capture: In general sense lead capture designates a process or way of…
Introduction Unlimited Modal POPUPS on MouseClick: Everyone knows about popup during site visits and most…
Brief about Pregnancy Calculator : This WordPress Pregnancy Calculator plugin allows users to display an…
Introduction About this Service Plugin: This Visual Composer Service Plugin works as an addon to…
Introduction of Dynamic Query String : This plugin allows user to set dynamic query string…
There is an occasional bug for iPhone and iPad even they are designed as well and…