Rasel Ahmed
Rasel Ahmed

Reputation: 305

Get search text value in URL

I have a form like this

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

When I add some keyword on search input text, The URL is going as http://domain.com/?s=keyword

I need it as http://domain.com/?s=keyword&post_type=events

Means I need just &post_type=event added on url. How can I do it? any suggestion?

Upvotes: 3

Views: 482

Answers (2)

user2050308
user2050308

Reputation:

Please try this code...

<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>

When you press button it return to like.

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

Upvotes: 1

Patrick
Patrick

Reputation: 922

Add a hidden field

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

Upvotes: 8

Related Questions