php - 具有 Polylang + 搜索栏功能的革命滑块
问题描述
我有这个代码:
<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。
有人可以帮忙吗?谢谢。
解决方案
默认情况下,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
推荐阅读
- .net - 为什么我的 EmailConfirmed 属性在更新并将其设置为 true 后一直恢复为 false
- c# - 如何解决 C# - SQlite 提供程序问题
- java - 为什么每次执行Array(1,2,3).toString()的结果都不一样,结果如何确定?
- c++ - Boost::Multi_Index 运行总计
- android - 在android studio中调用
- java - Java Spring JPA CORS 错误
- python - 当服务器未完全使用请求正文时连接重置
- tizen - Tizen TV - 如何在模拟器上启动应用程序?
- css - 当没有元素时,是否可以使用 CSS 选择器在列表中获取空字符串?
- javascript - 将自定义链接添加到 chartJS