用于去掉短代码中多余的p标签等。

方法一:

remove_filter('the_content', 'wpautop');
add_filter('the_content', 'wpautop', 99);
add_filter('the_content', 'shortcode_unautop', 100);

方法二:

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

发表回复

后才能评论