用于去掉短代码中多余的p标签等。
方法一:
- remove_filter(‘the_content’, ‘wpautop’);
- add_filter(‘the_content’, ‘wpautop’, 99);
- add_filter(‘the_content’, ‘shortcode_unautop’, 100);
方法二:
- if( !function_exists(‘zm_fix_shortcodes’) ) {
- function zm_fix_shortcodes($content){
- $array = array (
- ‘<p>[‘ => ‘[‘,
- ‘]</p>’ => ‘]’,
- ‘]<br />’ => ‘]’
- );
- $content = strtr($content, $array);
- return $content;
- }
- add_filter(‘the_content’, ‘zm_fix_shortcodes’);
- }