Shopify 从{{content\u for_header}编辑或更改注入的内容

Shopify 从{{content\u for_header}编辑或更改注入的内容,shopify,facebook-pixel,Shopify,Facebook Pixel,我的shopify商店的标题中仍然嵌入了一个fb像素。使用facebook pixel helper,它显示我的标题中仍然有一个fb像素。我查看了一下,发现它在我的{{content_for_header}}中 我已经尝试过.remove()和| remove:但我的主题标题中仍然有fb像素。liquid您可以删除或替换如下字符串 替换 {{ content_for_header | replace: 'string to be replaced', 'inserted' }} 除去 {{ c

我的shopify商店的标题中仍然嵌入了一个fb像素。使用facebook pixel helper,它显示我的标题中仍然有一个fb像素。我查看了一下,发现它在我的{{content_for_header}}中


我已经尝试过.remove()和| remove:但我的主题标题中仍然有fb像素。liquid

您可以删除或替换如下字符串

替换

{{ content_for_header | replace: 'string to be replaced', 'inserted' }}
除去

{{ content_for_header | remove: '' }}

否则,您无法真正编辑
{{content\u for_header}}

您不能使用
替换
删除
content\u for_header

{% capture custom_content_for_header %}
    {{ content_for_header | replace: 'your-text-to-be-replaced', 'new-text'
{% endcapture %}
不建议修改标题的
内容,但我将向您展示如何修改它

首先,评论一下

{%- comment -%}
  {{ content_for_header }}
{%- endcomment -%}
这将允许您使用
theme watch

其次,对自定义
content\u标题使用捕获

{% capture custom_content_for_header %}
    {{ content_for_header | replace: 'your-text-to-be-replaced', 'new-text'
{% endcapture %}
最后,打印标题的自定义内容

 {{ custom_content_for_header }}

如果您收到一个错误,说明\u头的内容\u不存在。尝试以下替代方法:
{%capture h_content%}{{content_for_header}{%endcapture%}{%if如果h_content包含“要替换的字符串”%%}{{h_content}替换:'inserted'}{%else%}{{content_for_header}{%endif%}