【问题标题】:Change storefront search field placeholder更改店面搜索字段占位符
【发布时间】:2019-07-10 08:36:39
【问题描述】:

提前致谢。 注意:NSFW 网站,可能是一些来自电子书封面的热门图片,没有裸体但成人浪漫封面。

好的,

我有 WP+storefront+bookshop 子主题,我想在搜索字段 (#woocommerce-product-search-field-0) 中更改占位符“搜索产品...”。无论我尝试什么,它似乎都不会影响占位符。

我可以更改搜索宽度、对齐方式、文本和边框颜色,但不能更改占位符…… 到目前为止的代码

> /*Align Search Bar and make text and border pink #fe00a1*/
> #woocommerce-product-search-field-0 { display:inline-block; width:100%; color: #fe00a1; border: solid 1px #fe00a1; }

我还尝试了几个 PHP sn-ps,允许我在 woocommerce 中更改几乎任何文本的最好的一个是这个 GETTEXT 过滤器

> function my_text_strings( $translated_text, $text, $domain ) { switch
> ( $translated_text ) { case ‘Search products…’ : $translated_text =
> __( ‘Search for contemporary romance books, series ot authors…’, ‘woocommerce’ ); break; } return $translated_text; } add_filter(
> ‘gettext’, ‘my_text_strings’, 20, 3 );

但是..是的,你猜对了,它没有用。

如何将锁定、隐藏或任何具有“搜索产品”的内容替换为“搜索当代浪漫书籍、系列或作者……”? CSS、PHP、一些技巧?

提前致谢。

【问题讨论】:

    标签: search woocommerce placeholder storefront


    【解决方案1】:

    好的,这就是解决方案,感谢来自wordpress.org的@jobthomas

    add_filter( 'gettext', 'my_text_strings', 20, 3);
    
        function my_text_strings( $translated, $text, $domain ) {
          $translated = str_ireplace( 'Search products', 'Search for contemporary books , series or authors', $translated );
          return $translated;
        }
    

    【讨论】:

      猜你喜欢
      • 2019-11-22
      • 1970-01-01
      • 2017-02-10
      • 2019-02-25
      • 1970-01-01
      • 2018-10-14
      • 2014-12-14
      • 1970-01-01
      • 2017-09-13
      相关资源
      最近更新 更多