0

I created a custom post type which I'll use as landing page for PPC. Now on that custom post type I would like to remove all the filters which are adding the social media buttons for example. I tried already with the following code but that did also remove the shortcode filter which I would like to keep on that custom post type. Here's the code I used:

    function landingpage_remove_plugin_filters() {

    global $wp_filter;
    global $wp;
    if ($wp->query_vars["post_type"] == 'landingpage') {
    remove_all_filters('the_content', 'plugin_filters');
    }
    }   

    add_action('wp','landingpage_remove_plugin_filters');

Does anyone know what I need to change in order to keep the shortcode filters on that custom post type?

Thanks a lot for your efforts.

Daniel

2

Try re-adding the 'do_shortcode' filter like so:

function landingpage_remove_plugin_filters() {

    global $wp_filter;
    global $wp;
    if ($wp->query_vars["post_type"] == 'landingpage') {
        remove_all_filters('the_content', 'plugin_filters');
        add_filter('the_content', 'do_shortcode');
    }
}   

add_action('wp','landingpage_remove_plugin_filters');
  • Thanks, this helped. I should have thought of that myself :-) – dwaser Aug 27 '11 at 9:38
  • Good to hear it. Could you mark the answer as accepted so that everyone knows this question has been solved? – Devin Humbert Aug 28 '11 at 8:30
0

remove_all_filters function removes all of the hooks from filter, and it only has two parameters $tag ( the filter to remove hooks from ) and $priority

if you want to remove all hooks from filter use remove_all_filters, but if you only want to remove hook named plugin_filters use remove_filter function

function landingpage_remove_plugin_filters() {
    global $post;

    if ( 'landingpage' == $post->post_type )
        remove_filter( 'the_content', 'plugin_filters' );
}
add_action( 'wp', 'landingpage_remove_plugin_filters' );
  • Thanks for the help. I tried your code too but it didn't remove the filters I wanted. I still got the social share buttons showing up. – dwaser Aug 27 '11 at 9:39
  • What plugin do you use for social sharing? – Mamaduka Aug 27 '11 at 9:58
  • I tested that with several plugins. One of them was: wordpress.org/extend/plugins/… – dwaser Aug 27 '11 at 10:05
  • In which file should I put this function? I would like to remove_all_filters("the_content") – qed Jul 28 '14 at 3:04
  • @qed It can be custom plugin or functions.php. – Mamaduka Jul 28 '14 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.