如何解决阻止p标签自动添加到Wordpress-Twig,ACF和过滤短代码中
当我用{%filter shortcodes%} {%endfilter%}包装代码时,WordPress会自动添加p标签。无论如何,我可以禁用此功能,因为我必须使用过滤器简码代码。我正在使用Twig和“高级自定义字段”,因此the_content对我不起作用。
这是我在functions.php文件中尝试过的内容:
add_filter('the_content','remove_unneeded_silly_p_tags_from_shortcodes');
function remove_unneeded_silly_p_tags_from_shortcodes($the_content){
$array = array (
'<p>[' => '[',//replace "<p>[" with "["
']</p>' => ']',//replace "]</p>" with "]"
']<br />' => ']' //replace "]<br />" with "]"
);
$the_content = strtr($the_content,$array); //replaces instances of the keys in the array with their values
return $the_content;
}
remove_filter( 'the_content','wpautop' );
add_filter( 'the_content','wpautop',99);
remove_filter ('acf_the_content','wpautop');
add_filter('acf_the_content','wpautop');
请帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。