I'd like to stop parsing shortcodes in the_content but I'm struggling to find what the correct filter would be. This didn't work:

remove_filter( 'the_content', 'do_shortcode', 40 );
remove_filter( 'the_content', 'run_shortcode', 40 );
remove_filter( 'the_content', 'wpautop', 40 );
remove_filter( 'the_content', 'autoembed', 40 );
remove_filter( 'the_content', 'prepend_attachment', 40 );

This worked (but also disabled all other useful filters):

remove_all_filters( 'the_content', 40 );

So, I'd like to disable autoembed and do_shortcode and let WordPress display them as plain text. Would it be possible? I'm using wp hook in main plugin's PHP file.

1 Answer 1


The correct way is calling remove_filter with the same priority as the hook was added:

remove_filter( 'the_content', 'do_shortcode', 11 );

Some plugins change this filter’s priority, so you could clear the global list of registered shortcodes temporary:

add_filter( 'the_content', 'toggle_shortcodes', -1 );
add_filter( 'the_content', 'toggle_shortcodes', PHP_INT_MAX );

function toggle_shortcodes( $content )
    static $original_shortcodes = array();

    if ( empty ( $original_shortcodes ) )
        $original_shortcodes = $GLOBALS['shortcode_tags'];
        $GLOBALS['shortcode_tags'] = array();
        $GLOBALS['shortcode_tags'] = $original_shortcodes;

    return $content;
  • Thanks, it works! But is this the only way to do that? Why not just remove_filter( 'the_content', 'do_shortcode', 40 );?
    – Paul
    Sep 22, 2013 at 13:20
  • @Paul 40 cannot work, because the priority is an array key. There is no entry for that filter at position 40, so the removal must fail.
    – fuxia
    Sep 22, 2013 at 13:21
  • I thought that it works like: add_filter( 'the_content', 'some_function', 10); and remove_filter( 'the_content', 'some_shortcode', 11);. Expected result: some_function() will not be added. Here they mention int for priority: codex.wordpress.org/Function_Reference/remove_filter so I'm a bit confused. It would be great if you could update your answer with a few more words of explanation that an average user would understand :) It works so this question is answered but I still wonder why my attempts failed.
    – Paul
    Sep 22, 2013 at 13:26
  • 2
    @Paul For an explanation of the structure of the global filter list, see this answer. You can see the priority as key there (5, 12, 20, 1000).
    – fuxia
    Sep 22, 2013 at 13:31

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.