Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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');
share|improve this answer
    
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
    
I just accepted the answer. Thanks for the reminder. –  dwaser Aug 28 '11 at 23:19

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' );
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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