【问题标题】:Revolution Slider with Polylang + Search bar function具有 Polylang + 搜索栏功能的革命滑块
【发布时间】:2021-06-25 14:24:15
【问题描述】:

我有这个代码:

<form role="search" method="get" id="searchform"
class="revtp-searchform" action="https://yourwebsitehere.com">
  <input type="text" value="" name="s" id="s" placeholder="Make your search here" />
  <input type="submit" id="searchsubmit" value="Find" />
</form>

问题是我希望有一个搜索栏用于我的英语版本和另一个用于我的西班牙语版本。使用上面的代码,它只查找我默认英文版本的帖子。我使用 Polylang。

有人可以帮忙吗?谢谢。

【问题讨论】:

    标签: php wordpress search polylang


    【解决方案1】:

    wordpress 默认提供一种显示搜索表单的功能

    get_search_form();
    
    

    如果它在主题中可用,它使用 searchform.php,否则它使用 wordpress 的默认搜索形式。您可以在您的子主题中创建一个名为 searchform.php 的文件并放在下面的代码中

    <form role="search" method="get" id="searchform"
    class="revtp-searchform" action="<?php echo esc_url(home_url('/') . 'index.php/' . pll_current_language() . '/'); ?>">
      <input type="text" value="" name="s" id="s" placeholder="Make your search here" />
      <input type="submit" id="searchsubmit" value="Find" />
    </form>
    
    //pll_current_language() will get current language of polylang
    
    

    【讨论】:

      猜你喜欢
      • 2017-08-22
      • 1970-01-01
      • 1970-01-01
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多