【问题标题】:WordPress multilingual search form with polylang带有 polylang 的 WordPress 多语言搜索表单
【发布时间】:2017-01-22 07:48:16
【问题描述】:

我使用 polylang 插件创建了一个多语言演示网站。我对这个插件非常满意,除了它处理搜索表单的方式。 当我尝试搜索任何内容时,菜单会消失,并且不会以所需的语言进行搜索。

【问题讨论】:

    标签: wordpress search multilingual search-form polylang


    【解决方案1】:

    我设法通过以下步骤解决了我的问题:

    我创建了一个文件 searchform.php 并输入了以下代码:

    // the . 'index.php/' part is not mandatory, my website works like this. you can try without it
    <form method="get" class="search-form form-inline" id="searchform"
          action="<?php echo esc_url(home_url('/') . 'index.php/' . pll_current_language() . '/'); ?>">
        <div class="input-group">
            <input type="text" class="search-field form-control" name="s" id="s" placeholder="<?php pll_e('Search'); ?>"/>
            <span class="input-group-btn">
          <button type="submit" class="search-submit btn btn-default"><?php pll_e('Search'); ?></button>
            </span>
        </div>
    </form>
    

    如果代码&lt;?php get_search_form(); ?&gt; 没有显示您的自定义表单,您可以随时使用:

      <?php get_template_part('searchform'); ?>
    

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 2023-03-10
      • 2018-03-11
      • 2021-07-03
      • 2020-02-15
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      • 1970-01-01
      相关资源
      最近更新 更多