阻止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 (将#修改为@)