Insert your own Search option in your wordpress theme

By -

 While developing you own theme many times you don’t want to use the default search of the wordpress and you want your own search option which looks better and suits your site design.So if you want to insert your own search option in the theme instead of the default search its very easy to implement it.

Now lets do that in the wordpress theme,

First of all add one function in the functions.php file in your theme folder.

This function creates your search view.And add it to the wordpress site where ever you want.

So lets define that function in functions.php file,

function custom_search_form() {
<form method="get" class="" action="<?php bloginfo('home'); ?>/">
<input type="text" value="" name="s" id="s"  />
<input type="submit" value="Go" />
<?php }
add_action('thesis_hook_header' , 'custom_search_form');

You can also use echo for the form display if you want.

Now you have to call this function in the page where you want to insert the search option.Basically you wish to add it to the header so that it can be seen throwout the site.But if you want to display it in some particular page just call the function you have just defined in the desired page.You can do this by putting below code,

 <div class="search">
        <?php custom_search_form(); ?>

Add your own class here instead of the search class of mine for your custom  search option in the site. And insert css for that class in the style.css file of your theme folder.

Above code will result in the site as,

Its done with the code.Now enjoy your searching.

hiii friends... i am doing msc in computer application and information technology. we are here to share our knowledge and idea on

Leave a Reply

Your email address will not be published. Required fields are marked *