wordpress 显示代码块,pre code标签

pre code标签的代码块无法正常显示,解决方法
依旧在主题文件functions.php中加入代码

add_filter( 'the_content', 'pre_content_filter', 0 ); 
function pre_content_filter( $content ) { 
    return preg_replace_callback( '|【pre.*】【code.*】(.*)【/code】【/pre】|isU' , 'convert_pre_entities', $content ); 
    }
function convert_pre_entities( $matches ) {
    return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] ); 
}

把上面代码中的【】替换成<>

版权声明:
作者:José
链接:https://www.josejang.com/about-work/127.html
来源:José's ⎝⏠⏝⏠⎠ Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>