【问题标题】:Prevent wordpress from appending CDATA to tag manager script防止 wordpress 将 CDATA 附加到标签管理器脚本
【发布时间】:2015-02-16 07:16:19
【问题描述】:

我正在为 Wordpress 使用 Google 跟踪代码管理器插件,而 WP 不断将 CDATA 添加到跟踪代码管理器脚本中,但 site 验证失败。在没有 CDATA 的情况下,我的其他简单 html 网站都得到了验证。

根据我找到的答案here,我将 wp-includes\post-template.php 第 167 行更改为此

$content = str_replace('<![CDATA[','',$content);
$content = str_replace(']]>','',$content);
//$content = str_replace(']]>', ']]&gt;', $content); 

但是,WP 仍在将 CDATA 添加到脚本中。

如何防止这种情况发生?还有其他方法吗?

【问题讨论】:

    标签: php wordpress cdata google-tag-manager


    【解决方案1】:

    在使用 Wordpress 开发我的一个网站时,我遇到了同样的问题。对我来说,问题是 W3 TOTAL Cache 插件将脚本包含在 CDATA 标记内。尝试停用插件并从 WP 管理仪表板手动清除缓存。

    【讨论】:

      猜你喜欢
      • 2021-12-23
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2015-12-05
      相关资源
      最近更新 更多