remove empty

tags from wordpress shortcodes vi

2019-03-24 16:28发布

Looking for a php function (non-jQuery or wpautop modification) approach to remove <p></p> from within wordpress.

I tried this but it does not work:

        function cleanup_shortcode_fix($content) {   
          $array = array (
            '<p>[' => '[', 
            ']</p>' => ']', 
            ']<br />' => ']',
            ']<br>' => ']'
          );
          $content = strtr($content, $array);
            return $content;
        }
        add_filter('the_content', 'cleanup_shortcode_fix');

7条回答
SAY GOODBYE
2楼-- · 2019-03-24 17:12

add_filter('the_content', 'cleanup_shortcode_fix', 10);

I found that it works if you specify 10 as the priority; no other number will work.

查看更多
登录 后发表回答