Search code examples
phpwordpressshortcode

How to disable shordcode in a category description backend, in admin area?


I have enabled shortcodes in pretty much everywhere by adding this line:

add_filter( 'term_description', 'do_shortcode' );

Unfortunately it now shows in admin area, in the category tab, in the description of a category where the shortcode is present. I only want it to be executed on an actual page, I don't need to preview it in the admin area.

Is there a way of disabling it being executed in the admin area?


Solution

  • https://codex.wordpress.org/Function_Reference/is_admin

    Is this what you're seeking?

    if( is_admin() == false )
    {
      add_filter( 'term_description', 'do_shortcode' );
    }