1

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

4

1 回答 1

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>

如果代码<?php get_search_form(); ?>不显示您的自定义表单,您可以随时使用:

  <?php get_template_part('searchform'); ?>
于 2017-01-22T07:48:16.040 回答