apply_filters(‘the_content’) – make it ignore shortcodes?

I am using apply_filters('the_content) so I can see properly formatted content inside my wp editor in the backend.

However, this also renders the shortcode that’s in the content.

Read More

I want it to ignore the shortcode and apply filtering to the rest of the content, basically the same thing as when making posts. If you view post content in the backend, you will see the shortcode, but if you view it inside a page on your website, you will see the rendered shortcode (its result).

Is this possible?

Related posts

Leave a Reply

1 comment

  1. The function that parses the shortcode, do_shortcode is added as a filter on the_content by default, at priority 11.

    You can remove it using remove_filter:

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

    Call this right before you’re actually using the_content, and add it afterwards (in the unlikely case that it’s needed after that):

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