【问题标题】:wordpress stripping out apostrophes in the_titlewordpress 去掉 the_title 中的撇号
【发布时间】:2011-05-11 16:00:53
【问题描述】:

我正在运行 Wordpress 循环,当我显示 the_title() 时,它会删除所有撇号...

Matt's Books 的内容显示为Matts Books

我对formatting.php、post-template.php 和其他页面以及codex 进行了一些研究,但未能找到答案。

任何帮助将不胜感激。

编辑

这个问题的答案是简单地注释掉 wp-includes/default-filters.php 的第 103 行:

// Default Filters
// add_filter( 'the_title', 'wptexturize'   ); /*comment out this line */

【问题讨论】:

  • 如果你要写撇号,你应该首先了解它们是什么。我已经修正了你的问题标题和正文。

标签: php wordpress


【解决方案1】:

Hacking WordPress Core 绝不是个好主意。

wptexturize 过滤器将字符转换为适当的 HTML 实体。如果它没有正确转换撇号字符,则可能是字符编码设置问题,或者很可能是您使用的主题存在问题。

您在设置 - 阅读设置中设置的字符编码是什么?

如果您想删除 wptexturize 过滤器,正确的方法是将其添加到您的 functions.php 中

remove_filter ('the_title', 'wptexturize'); 

【讨论】:

    【解决方案2】:

    我怀疑这可能是您使用的特定主题的问题。

    尝试用 html 代码 ' 代替撇号。

    也可以看看这篇与相同问题相关的博文:http://takethu.com/blog/2006/09/01/wordpress-curlification-of-apostrophe-in-title/

    【讨论】:

    【解决方案3】:

    尝试像这样呼应网站的标题:

    <title><?php echo "Someone's Website" ?></title>
    

    它不会转义撇号。

    【讨论】:

      猜你喜欢
      • 2020-12-13
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-23
      • 2019-06-13
      相关资源
      最近更新 更多