I have a form in my wordpress theme. I want add a “plus” to space in url.
My source code:
<form method="get" id="searchform" action="/search/" onsubmit="return false;">
<input type="text" name="s" id="s" placeholder="Search" />
<input type="submit" class="submit" id="searchsubmit" value="<?php esc_attr_e( '', 'themeO' ); ?>" onclick="window.location.href=this.form.action + this.form.s.value;" />
</form>
my actual search url – keyword : “good job”
http://www.example.com/search/good job
I need this url:
http://www.example.com/search/good+job
You can use
replace()
to replace spaces with pluses: