获取 URL 中的搜索文本值


Get search text value in URL

我有这样的表格

<form method="get" id="searchform" action="http://domain.com">
    <input name="s" id="s" type="text" />
    <input type="submit" id="searchsubmit" type="submit" />
</form>

当我在搜索输入文本上添加一些关键字时,URL 将按 http://domain.com/?s=keyword

我需要它作为 http://domain.com/?s=keyword&post_type=events

意味着我只需要在网址上添加 &post_type=事件。我该怎么做?有什么建议吗?

添加隐藏字段

<input type="hidden" name="post_type" value="events">

请尝试此代码...

<form method="get" id="searchform" action="http://domain.com">
    <input name="s" id="s" type="text" />
    <input type="submit" id="searchsubmit" name="post_type" value='event'/>
</form>

当您按下按钮时,它会返回到喜欢。

http://domain.com/?s=keyword&post_type=events