【问题标题】:Search box is using post title as prefix搜索框使用帖子标题作为前缀
【发布时间】:2016-06-12 21:39:51
【问题描述】:

我的网站上的搜索框有问题。问题是,如果有人从帖子中搜索,它会将他重定向到http://example.com/post-title/?s=test 而不是http://example.com/?s=test。从主页搜索当然可以正常工作。

我正在使用 Simple Custom Css 插件来管理自定义 css。有存储我的 CSS 用于搜索框。

搜索框代码如下所示:

<form class="form-wrapper cf" style="margin-left:85px; margin-bottom:30px">
    <input type="text" name="s" placeholder="Search..." oninvalid="this.setCustomValidity('Error!')" required="">
    <button type="submit">Search</button>
</form>

你知道哪里出了问题吗?

【问题讨论】:

  • CSS 在这里没有发挥作用。

标签: php wordpress forms


【解决方案1】:

当你说它在主页上可以正常工作时,给action 属性并将其设置为主页然后:

<form class="form-wrapper cf" action="/" style="margin-left: 85px; margin-bottom: 30px">
<!----------------------------^^^^^^^^^^

这样,它将确保始终在http://example.com而不是当前页面上执行搜索,因为空的或不存在的action属性将提交到同一页面。

【讨论】:

    猜你喜欢
    • 2023-01-05
    • 2011-12-19
    • 1970-01-01
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 2018-08-29
    • 1970-01-01
    相关资源
    最近更新 更多