欢迎来到抓润网

WordPress禁止将英文半角符号转换成全角符号_WordPress教程_抓润网

来源: 互联网 日期: 2020-07-16 17:07:03

今天客户的网站刚用到的,记录一下,以后就知道了。菜单选项的转义用the_title即可解决。

WordPress 模式使用了 wptexturize函数将纯文本字符转换成格式化的 HTML 实体。

标签 <pre>, <code>, <kbd>, <style>, <script>和<tt>中的文本被忽略。

对于一般写单纯码文字的人来说,这个自动将英文半角符号转换成全角符号,是很方便、智能。

但如果你经常要粘贴一些代码,而且没有使用专门的代码高亮插件,你会发现,你代码中的半角符号都会被转换成全角了!别人复制后,根本没办法直接使用!

禁止字符转义的所有代码如下,你可以根据自己的需要,选自己要的代码,添加到主题的 functions.php 文件:

// 取消转义 Quotmarks Replacer 
$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');
}

当然,你还可以将上面的代码分别下面的形式:

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

如果不想修改代码的,直接下载安装 Quotmarks Replacer 插件。

(抓润网帝国模板 www.zhuarun.com)


上一篇:WordPress升级时遇到’另一更新正在进行’的解决方法_WordPress教程_抓润网

下一篇:WordPress在LNMP环境下网站二级目录伪静态设置教程_WordPress教程_抓润网

  • 在线客服

    点击这里给我发消息 点击这里给我发消息

    官方微信

    仅处理投诉、举报及平台使用问题;
    商品问题请咨询商家客服!

浏览记录