php - 获取 URL 中的搜索文本值

标签 php wordpress

我有这样的表格

<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

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

最佳答案

添加隐藏字段

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

关于php - 获取 URL 中的搜索文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19310795/

相关文章:

php - 使用 PHP 根据类别 ID 过滤帖子

php - IF 语句未按预期运行

php - 带有 mt_rand 的 Var_Dump

html - 报纸 Wordpress 主题中移动设备上的图像宽度 100%

php - 将自定义订单状态设置为对付款有效

PHP 去掉未知文件扩展名

php - 使用单个查询搜索同一表中不同列中的每个单词

javascript - 删除渲染阻止 JavaScript :

wordpress - 如何使 "Max Mega Menu"适用于我的自定义主题?

mysql - 我在更新 wp_post 时收到 'Query execution was interrupted' 错误?