【问题标题】:Why Wordpres custom HTML block is changing my code?为什么 Wordpress 自定义 HTML 块正在更改我的代码?
【发布时间】:2022-01-19 21:12:20
【问题描述】:

我正在使用“地理定位 IP 检测”插件,以便为访问者提供本地化的亚马逊联盟链接。

当我在自定义 HTML 块中输入类似内容时:

[geoip_detect2_show_if country="MX"]
<div class="wp-block-buttons is-content-justification-center">
 <!--wp:button {"backgroundColor":"luminous-vivid- 
  orange","textColor":"white","className":"is-style-fill"} -->
 <div class="wp-block-button is-style-fill">
  <a class="wp-block-button__link has-white-color has-luminous- 
    vivid-orange-background-color has-text-color has-background" href="https://amzn.to/example" target="_blank" rel="noreferrer noopener nofollow">See on Amazon</a>
 </div>
 <!-- /wp:button -->
</div>
[/geoip_detect2_show_if]

当我回到编辑器时,我在自定义 HTML 块中得到了这个:

[geoip_detect2_show_if country="MX"]
<div class="wp-block-buttons is-content-justification-center"></div>
[/geoip_detect2_show_if]

链接在编辑器中被删除。这些块似乎工作正常(提供本地化链接),但如果我再次保存页面,没有链接的代码会更新到页面中。

【问题讨论】:

    标签: wordpress custom-wordpress-pages wordpress-shortcode


    【解决方案1】:

    看起来您正在使用古腾堡编辑器。 尝试在自定义 html 块之前和之后使用专用的短代码块来构建布局。 因此,顶部短代码块中的 [geoip_detect2_show_if country="MX"],自定义 html 块中的自定义 html(如果不需要,请删除注释项目),然后是短代码块中的 [/geoip_detect2_show_if]之后。

    【讨论】:

      猜你喜欢
      • 2020-04-12
      • 1970-01-01
      • 1970-01-01
      • 2011-06-16
      • 2022-11-11
      • 2015-06-08
      • 1970-01-01
      • 2014-05-29
      • 2020-06-02
      相关资源
      最近更新 更多