禁止WordPress 4.8版本自动将英文半角符号转换成全角符号

WordPress自动将英文半角符号转换成全角符号是因为WordPress的一个函数wptexturize()在作怪,既然如此,那就移除它。将下面的代码加入主题的模板函数funtions.php文件中,注意是加在最后一个 ?>之前:

//取消内容转义
remove_filter('the_content', 'wptexturize');
//取消摘要转义
remove_filter('the_excerpt', 'wptexturize');
//取消评论转义
remove_filter('comment_text', 'wptexturize');

至此,我已经完美解决了禁止WordPress自动将英文半角符号转换成全角符号这个问题了!

禁止WordPress自动将半角标点符号替换为全角

WordPress什么都好,就是这个自动把半角符号替换为全角十分恶心(除了code标签里的内容不转换)。经常发现从别人博客里复制下来的代码出错,一看全是全角标点,实在搞不明白WordPress为什么要做这么一个多此一举的行为。

现把解决方法记录下,防止自己犯错,顺便备忘,再顺便测试下是否有效。

Pop注:WordPress 4.1之前版本可以使用,4.8版本请参见
禁止WordPress 4.8版本自动将英文半角符号转换成全角符号
http://429006.com/article/technology/3929.htm

1、 编辑 wp-includes/formatting.php 文件,找到以下代码:

// This is not a tag, nor is the texturization disabled static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

2、 将$curl 开头的两句代码注释掉,最终的代码如下:

// This is not a tag, nor is the texturization disabled static strings
//$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
//$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

原文地址:
http://www.coolfou.com/chinese-version-of-wordpress-will-automatically-prohibit-punctuation-replaced-with-full-width-half-width.htm