默认WordPress 会自动在 shortcode 内添加 br 或者 p 标签,可能会打乱你的原先预想的 HTML 结构和布局。
成这个问题的原因是 WordPress 默认的日志内容处理流程中,wpautop(将回车转换成 p 或者 br 标签的函数)是在 Shortcode 前面运行的。所以我们的解决方案也是非常简单,改变它们执行的顺序,在当前主题的 functions.php 文件中添加:
- remove_filter( \’the_content\’, \’wpautop\’ );
- add_filter( \’the_content\’, \’wpautop\’ , 12);
原文:http://blog.wpjam.com/m/solution-to-wordpress-adding-br-and-p-tags-around-shortcodes/
暂无评论内容