当前所在位置: 首页>>百科全书

WordPress取消英文标点符号自动替换中文标点符号的优雅方法

发布时间:2025-10-23 09:53:25 本站作者 【 字体: 】 浏览:45 次

众所周知,WordPress中文版有个特性,会将每一处英文引号("")都稀里哗啦转化为中文引号(“”)。不仅仅是英文引号,在WordPress翻译文件定义了不少自动转换符号,具体可以参考这里

对文字博客来说,这是个好功能,这样会避免用错英文标点。

然而,WordPress是独立的php程序,中文社区中懂得使用者,大部分都是技术博客。而技术博客会经常贴出代码,里面包含各种英文标点是再正常不过的事情。这时候,英文标点符号自动转换就是一个恼人的画蛇添足功能了。

网上很多文章都是让该WordPress核心文件。只不过,WordPress是一个高度模块化的系统,肯定有更优雅的解决方案。

一番搜寻之后,发现最简单的办法,就是安装一个叫Quotmarks Replacer的插件,地址在这里

插件很简单,就是将WordPress自动转换标点符号的函数用系统接口去掉。核心代码如下:

<?php
/*
Plugin Name: Quotmarks Replacer
Plugin URI: http://sparanoid.com/work/quotmarks-replacer/
Description: Quotmarks Replacer disables wptexturize function that keeps all quotation marks and suspension points in half-width form.
Version: 2.6.17
Author: Tunghsiao Liu
Author URI: http://sparanoid.com/
Author EmAIl: t@sparanoid.com
License: GPLv2 or later
Copyright 2016 Tunghsiao Liu, aka. Sparanoid (t@sparanoid.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
$qmr_work_tags = array(
'the_title',             // http://codex.wordpress.org/Function_Reference/the_title
'the_content',           // http://codex.wordpress.org/Function_Reference/the_content
'the_excerpt',           // http://codex.wordpress.org/Function_Reference/the_excerpt
// 'list_cats',          Deprecated. http://codex.wordpress.org/Function_Reference/list_cats
'single_post_title',     // http://codex.wordpress.org/Function_Reference/single_post_title
'comment_author',        // http://codex.wordpress.org/Function_Reference/comment_author
'comment_text',          // http://codex.wordpress.org/Function_Reference/comment_text
// 'link_name',          Deprecated.
// 'link_notes',         Deprecated.
'link_description',      // Deprecated, but still widely used.
'bloginfo',              // http://codex.wordpress.org/Function_Reference/bloginfo
'wp_title',              // http://codex.wordpress.org/Function_Reference/wp_title
'term_description',      // http://codex.wordpress.org/Function_Reference/term_description
'category_description',  // http://codex.wordpress.org/Function_Reference/category_description
'widget_title',          // Used by all widgets in themes
'widget_text'            // Used by all widgets in themes
);
foreach ( $qmr_work_tags as $qmr_work_tag ) {
remove_filter ($qmr_work_tag, 'wptexturize');
}

当然你也可以参考这篇文章:https://www.freexyz.cn/cms/bee94fdf6816331685a559f0aec28cfd.html


上一篇:如何手动将本地WordPress站点迁移到主机/服务器?

下一篇:Win10电脑skype一直转圈登录不了怎么办?

最新发布
PS4Slim变7吋掌机!大神改造视觉PG街头涂鸦实机展示

PS4Slim变7吋掌机!大神改造视觉PG街头涂鸦实机展示

PS4Slim变7吋掌机!大神改造视觉PG街头涂鸦实机展示
随着掌机市场持续升温,一位改装大神成功将PS4 Slim改造成7吋OLED掌机,并公开结合PG街头涂鸦视觉风格的实机展示画面,迅速吸引PG电子玩家关注。该设备可稳定运行主机内容,续航约3小时,并对主板结构与散热系统进行深度重构,搭配独立风扇与实时温控设计,确保试玩过程顺畅稳定。7 吋OLED屏幕带来更出色的画面表现,提升PG...
PPT文字怎么转换成SmartArt图形?PPT文字转为SmartArt图形的方法

PPT文字怎么转换成SmartArt图形?PPT文字转为SmartArt图形的方法

PPT文字怎么转换成SmartArt图形?PPT文字转为SmartArt图形的方法
PPT文字怎么转换成SmartArt图形?SmartArt是一项图形功能,可以快速、轻松、有效地传达信息,如果你的PPT中如果有多段文字并列显示,那么可以将其转换为SmartArt图形,下面我们来看看这篇PPT文字转为SmartArt图形的方法吧。具体操作如下:打开PPT,建立空白演示文稿。在幻灯片中插入文本框,文本框内有多个...
PPT如何制作彩色色块拼接字?PPT彩色色块拼接字制作教程

PPT如何制作彩色色块拼接字?PPT彩色色块拼接字制作教程

PPT如何制作彩色色块拼接字?PPT彩色色块拼接字制作教程
PPT如何制作彩色色块拼接字?PPT是款十分专业且实用的文档演示软件,近期有用户想要对PPT内的文字进行重新设计,将其制作成彩色色块拼接字,那么应该如何操作呢?不清楚具体步骤的朋友们可以来看看下面这篇教程。打开PPT,建立空白文稿。点击【插入】—【文本框】,单击鼠标,输入一个文字。选择一种字体,...
PPT如何绘制三线表格?PPT制作三线表的方法

PPT如何绘制三线表格?PPT制作三线表的方法

PPT如何绘制三线表格?PPT制作三线表的方法
PPT如何绘制三线表格?在我们日常PPT文档的编辑中,我们会添加各种表格来丰富文档内容,近期有用户想要在PPT中制作三线表,那么应该如何操作呢?不清楚具体步骤的朋友们,可以跟着下面这篇教程来操作。打开PPT,建立空白幻灯片。点击【插入】—【表格】,得到默认样式的表格。在表格中录入文字和数据。...