问题描述
当我用{%filter shortcodes%} {%endfilter%}包装代码时,wordpress会自动添加p标签。无论如何,我可以禁用此功能,因为我必须使用过滤器简码代码。我正在使用Twig和“高级自定义字段”,因此the_content对我不起作用。
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 (将#修改为@)