How I search my WordPress site pages with search box I placed in my site? Currently I am using this code.
<form id="searchform" method="get" action="<?php bloginfo('siteurl')?>/" style="margin-left: -43px;">
<input type="text" name="" id="s" class="textbox" placeholder="Search" required/>
<input id="btnSearch" type="submit" name="submit" value="<?php _e('Search'); ?>" />
</form>
I used name="s" but it not do search properly. I want that if user right page1 name search box take it to siteurl/page1 and so for page2 and remaining page.
Thanks in advance
Try this :
Add above code in your
functions.php
file.So now when you type something, it will redirect it to that page.
NOTE:If you type something related to the published post, it will redirect to that POST instead of what have you entered.
For example : If I type
hello
in search box, then it will redirect you tohello world
(which is default post that comes during installation of wordpress).This is what have for you.