Support » Fixing WordPress » add search box in header

  • Resolved nun


    I’d like to add a search box to my header — preferably next to the RSS icon. What coding is needed and where would I put it in header.php? Many thanks.

    Sister Julie at

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Sister Julie,

    Please add this to your header.php file beside the RSS icon.

    <form method=”get” id=”searchform” action=”<?php bloginfo(‘home’); ?>/”>
    <div><input type=”text” size=”18″ value=”<?php echo wp_specialchars($s, 1); ?>” name=”s” id=”s” />
    <input type=”submit” id=”searchsubmit” value=”Search” class=”btn” />

    Let me know how it goes.

    God Bless 🙂

    What kulpreetsingh said is absolutly correct.
    I just wanted to add two small things for other people’s sake also :

    1. if your template supports it you can just add :
    <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

    2.adding the following code will put a text inside the search box.
    (like “Write your search and hit Enter” )

    <form method=”get” id=”searchform” action=”<?php bloginfo(‘home’); ?>/”>
    <div><input type=”text” size=”put_a_size_here” name=”s” id=”s” value=”Write your search and hit Enter” onfocus=”if(this.value==this.defaultValue)this.value=”;” onblur=”if(this.value==”)this.value=this.defaultValue;”/>
    <input type=”submit” id=”searchsubmit” value=”Search” class=”btn” />

    and finally, combining those two advices, just save the code from part two as searchform.php in your template folder, and you can always call it with method number 1.

    Great points krembo99 🙂

    kulpreetsingh and krembo99 — Thank you so much for your prompt attention and assistance. I combined what you both said and came up with something that works perfectly. I think the green bar must have limits on it because when I tried to put the search box there it kicked it to the center of the line below. So I moved it up and I think it fits better there. I even tried the text in the box thing with a little biblical twist! 🙂

    I’ve only been on for the last week and so am brand new to this coding thing. It helped to have quick, straight up solutions from both of you. Many thanks! Blessings,
    Sister Julie

    Haha! Seek and you will find. This is true. 🙂

    Looks good. You can also style it with CSS if you feel so inclined.


    I’m also trying to do the same thing but place the Search box to the right of my header title. There’s a bit of disused space there that I’d like to use instead of placing the search box in a sidebar.

    Any help much appreciated.



    I am trying to add the reverse, an rss icon into the header, any help appreciated.

    Thank you KREMBO!!!!

    great, simple solution- works a charm. can’t be any better forum answer than that. thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘add search box in header’ is closed to new replies.