Search box in Header Menu
  • How to set search-box as a last position in header menu?

    I've already customized a few things with child template, but I don't know if I should alter the header menu or go deeper and override functions in functions.php file.
  • Copy header.php from Responsive to Responsive Child Theme and add this in:
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    and styles
    #header #search-box {
        clear:right;
        float:right;
        margin:20px -20px 0 0;
        width:30%;
    }
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    

    Emil
    kuszimy wrote:
    How to set search-box as a last position in header menu?

    I've already customized a few things with child template, but I don't know if I should alter the header menu or go deeper and override functions in functions.php file.
  • Thanks for quick reply, but I'm trying to avoid solving this problem with CSS.


    Is there any way to pass additional parameter to wp_nav_menu,
    <?php wp_nav_menu(array(
          'container'       => '',
          'theme_location'  => 'header-menu')
          ); 
    ?>
    

    so that in HTML source code it would look like:
    <ul class='header-menu'>
          <li>option 1</li>
          <li>option 2</li>
          <li>option 3</li>
          <li><form id="searchform"><input type="text"></form></li>
    </ul>
    
  • The CSS was extras in case that you want to style this, the box will not go on it's own there, it needs some styles ;)
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    And follow the instructions above.

    Emil
    kuszimy wrote:
    Thanks for quick reply, but I'm trying to avoid solving this problem with CSS.


    Is there any way to pass additional parameter to wp_nav_menu,
    <?php wp_nav_menu(array(
          'container'       => '',
          'theme_location'  => 'header-menu')
          ); 
    ?>
    

    so that in HTML source code it would look like:
    <ul class='header-menu'>
          <li>option 1</li>
          <li>option 2</li>
          <li>option 3</li>
          <li><form id="searchform"><input type="text"></form></li>
    </ul>
    
  • Hi, I've tried doing the above as you suggested, but I either get the search box above the menu or below the menu, depending on where I put the div.
    <div id="search-box">
            <?php get_search_form(); ?>
    </div><!-- end of #search-box -->
    
    <?php wp_nav_menu(array(
        'container'       => '',
        'theme_location'  => 'header-menu')
        ); 
    ?>
    

    How do I make it inside the menu bar on the far right? Similar to http://themeid.com/forum/misc.php?action=pun_attachment&item=25&preview.
    You can see my website at http://www.lutfitorla.com/.

    Thank you.
  • Have you tried using margins/paddings to push it down?

    Emil
    Hi, I've tried doing the above as you suggested, but I either get the search box above the menu or below the menu, depending on where I put the div.
    <div id="search-box">
            <?php get_search_form(); ?>
    </div><!-- end of #search-box --> 
    </div><!-- end of col-300 fit -->
    
    <?php wp_nav_menu(array(
        'container'       => '',
        'theme_location'  => 'header-menu')
        ); 
    ?>
    

    How do I make it inside the menu bar on the far right? Similar to http://themeid.com/forum/misc.php?action=pun_attachment&item=25&preview.
    You can see my website at http://www.lutfitorla.com/.

    Thank you.
  • At first I couldn't figure out what you meant by "using margins to push it down" because wehenever I did it, everything else (including the menu) would go down as well. Then I remembered negative margins. Here's my new code, edited from your CSS code above. The code in header.php is the same as what you've given.
    #header #search-box {
        clear:right;
        zoom: 1;           //IE hack
        position:relative; //IE hack
        float:right;
        margin:60px -25px -60px 0;
        width:300px;}
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    
    The margins 60px & -60px can be changed based on your own website (if you want to make it pixel perfect). Keep them the same (i.e. 73px & -73px). Smaller number moves it up. Bigger number moves it down.


    The following code goes later on into each of the media queries (all 3 of them) at the bottom of the child theme css.
    #header #search-box {margin:5px -20px 0px 0;}
    
    This is important so that the search box moves above the menu on smaller screen devices.

    You can see how it works now at my website.

    Thank you for the help.
  • Looks pretty good!

    Emil
    At first I couldn't figure out what you meant by "using margins to push it down" because wehenever I did it, everything else (including the menu) would go down as well. Then I remembered negative margins. Here's my new code, edited from your CSS code above. The code in header.php is the same as what you've given.
    #header #search-box {
        clear:right;
        zoom: 1;           //IE hack
        position:relative; //IE hack
        float:right;
        margin:60px -25px -60px 0;
        width:300px;}
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    
    The margins 60px & -60px can be changed based on your own website (if you want to make it pixel perfect). Keep them the same (i.e. 73px & -73px). Smaller number moves it up. Bigger number moves it down.


    The following code goes later on into each of the media queries (all 3 of them) at the bottom of the child theme css.
    #header #search-box {margin:5px -20px 0px 0;}
    
    This is important so that the search box moves above the menu on smaller screen devices.

    You can see how it works now at my website.

    Thank you for the help.
  • Hey, I've moved the search bar into the menu bar as described, but I'm having trouble getting it to move below or above the menu when I resize: http://contactcustomerservice.co.uk/

    I'm not sure if I've put the bar in the right place in my header.php file. Any help very much appreciated!
  • You will need to add few more lines into "Media Queries" (Responsive Layout). Good start will be
    #header #search-box {
        clear:none;
        float:none;
        margin:0;
    }
    

    Thanks,
    Emil
    P.S. Assuming this is modified via Child Theme and look for media queries at the bottom of your style.css and there will be 3 places (different screens) where to put this in.

    Hey, I've moved the search bar into the menu bar as described, but I'm having trouble getting it to move below or above the menu when I resize: http://contactcustomerservice.co.uk/

    I'm not sure if I've put the bar in the right place in my header.php file. Any help very much appreciated!
  • Hi Emil, many thanks, I've opted for a different approach now, the search bar simply disappears. Client is happy with that so it'll be fine :)
  • Super!

    Emil
    Hi Emil, many thanks, I've opted for a different approach now, the search bar simply disappears. Client is happy with that so it'll be fine :)
  • Hey, I've moved the search bar into the menu bar as described, but I'm having trouble getting it to move below or above the menu when I resize: http://contactcustomerservice.co.uk/

    I'm not sure if I've put the bar in the right place in my header.php file. Any help very much appreciated!

    Hey guys! First experience in WP and couldn't be having a better first experience with a theme, so big thanks to Emil and others involved!

    Old post, but I was linked to this one from a new post and figured it'd be the best place to ask this question. Following this fellow's link, I really like how he put the search bar in the Top Nav like that. Probably a simple situation, but how exactly did he get it inside there? Currently running a child theme with just Ulrich's header widget .php files in it so far.

    Thanks for any help :)

    Mike
  • You do not need to use my header widget as Emil has added on directly to the theme as top widget.

    I found this solution recently. You might like this more.
    http://www.wprecipes.com/how-to-automatically-add-a-search-field-to-your-navigation-menu

    Ulrich
  • Copy header.php from Responsive to Responsive Child Theme and add this in:
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    Nice plugin, where exactly do we paste that piece of code in?
  • I placed it after the 'logo' div in my child theme's "header.php", just prior to
    <?php get_sidebar('top'); ?>
    

    I want the search field in the header itself, level with my logo, so I don't shift it down too much. The problem I'm experiencing is that the submit button is positioned below the search field, whereas I want it positioned to the right. I tried the following additional css:
    #header #search-box #s {
        float: left;
    }
    
    #header #search-box #searchsubmit {
        float: right;
    }
    

    Even though this positions the button to the right, it's still stuck beneath the search field.
    pjs wrote:
    Copy header.php from Responsive to Responsive Child Theme and add this in:
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    Nice plugin, where exactly do we paste that piece of code in?
  • is there a live site?

    Thanks,
    Emil
    chrism wrote:
    I placed it after the 'logo' div in my child theme's "header.php", just prior to
    <?php get_sidebar('top'); ?>
    

    I want the search field in the header itself, level with my logo, so I don't shift it down too much. The problem I'm experiencing is that the submit button is positioned below the search field, whereas I want it positioned to the right. I tried the following additional css:
    #header #search-box #s {
        float: left;
    }
    
    #header #search-box #searchsubmit {
        float: right;
    }
    

    Even though this positions the button to the right, it's still stuck beneath the search field.
    pjs wrote:
    Copy header.php from Responsive to Responsive Child Theme and add this in:
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    Nice plugin, where exactly do we paste that piece of code in?
  • No, sorry Emil, just on localhost (WebMatrix).

    Is it possible to post screenshots, or just online images?
    is there a live site?

    Thanks,
    Emil
    chrism wrote:
    I placed it after the 'logo' div in my child theme's "header.php", just prior to
    <?php get_sidebar('top'); ?>
    

    I want the search field in the header itself, level with my logo, so I don't shift it down too much. The problem I'm experiencing is that the submit button is positioned below the search field, whereas I want it positioned to the right. I tried the following additional css:
    #header #search-box #s {
        float: left;
    }
    
    #header #search-box #searchsubmit {
        float: right;
    }
    

    Even though this positions the button to the right, it's still stuck beneath the search field.
    pjs wrote:

    Nice plugin, where exactly do we paste that piece of code in?
  • please do :)

    Emil
    chrism wrote:
    No, sorry Emil, just on localhost (WebMatrix).

    Is it possible to post screenshots, or just online images?
    is there a live site?

    Thanks,
    Emil
    chrism wrote:
    I placed it after the 'logo' div in my child theme's "header.php", just prior to
    <?php get_sidebar('top'); ?>
    

    I want the search field in the header itself, level with my logo, so I don't shift it down too much. The problem I'm experiencing is that the submit button is positioned below the search field, whereas I want it positioned to the right. I tried the following additional css:
    #header #search-box #s {
        float: left;
    }
    
    #header #search-box #searchsubmit {
        float: right;
    }
    

    Even though this positions the button to the right, it's still stuck beneath the search field.
  • Here's a pic (the logo is changing, obviously!):

    34j4upi.png

    Perhaps it's something to do with the additional div at the top for the menubar?
    please do :)

    Emil
    chrism wrote:
    No, sorry Emil, just on localhost (WebMatrix).

    Is it possible to post screenshots, or just online images?
    is there a live site?

    Thanks,
    Emil
  • is this one of latest versions of Responsive Theme?
    chrism wrote:
    Here's a pic (the logo is changing, obviously!):

    34j4upi.png

    Perhaps it's something to do with the additional div at the top for the menubar?
    please do :)

    Emil
    chrism wrote:
    No, sorry Emil, just on localhost (WebMatrix).

    Is it possible to post screenshots, or just online images?
  • Indeed it is. I installed it via the WordPress theme installer, and it's up to date (WP is 3.4.2, running on WebMatrix). All modifications have been to the child. I started with your template, and so far I've just copied over home.php and header.php (only change in home.php is the color of the call-to-action button).

    I have the Q & A FAQ plugin installed, and I'm also getting a repositioned button in the plugin's FAQ search box, on a different page:

    2h37pt2.png

    Perhaps the plugin is interfering with the default (I doubt it). The button on the sidebar search box is unaffected.
    is this one of latest versions of Responsive Theme?
    chrism wrote:
    Here's a pic (the logo is changing, obviously!):

    34j4upi.png

    Perhaps it's something to do with the additional div at the top for the menubar?
    please do :)

    Emil
  • Hi,

    Just tested: http://themeid.com/demo/test/ and what I did here was plain search widget drag + drop in the Top Widget.

    dodYu.png

    was that how you have it?

    Thanks,
    Emil
    chrism wrote:
    Indeed it is. I installed it via the WordPress theme installer, and it's up to date (WP is 3.4.2, running on WebMatrix). All modifications have been to the child. I started with your template, and so far I've just copied over home.php and header.php (only change in home.php is the color of the call-to-action button).

    I have the Q & A FAQ plugin installed, and I'm also getting a repositioned button in the plugin's FAQ search box, on a different page:

    2h37pt2.png

    Perhaps the plugin is interfering with the default (I doubt it). The button on the sidebar search box is unaffected.
    is this one of latest versions of Responsive Theme?
    chrism wrote:
    Here's a pic (the logo is changing, obviously!):

    34j4upi.png

    Perhaps it's something to do with the additional div at the top for the menubar?
  • Ah yes that works! :) I just need to add a bit of css to reposition it level with the logo. Thanks again Emil!

    Best,
    Chris
    Hi,

    Just tested: http://themeid.com/demo/test/ and what I did here was plain search widget drag + drop in the Top Widget.

    dodYu.png

    was that how you have it?

    Thanks,
    Emil
  • .top-widget {
        padding-top: 33px;
    }
    

    Thanks,
    Emil
    chrism wrote:
    Ah yes that works! :) I just need to add a bit of css to reposition it level with the logo. Thanks again Emil!

    Best,
    Chris
    Hi,

    Just tested: http://themeid.com/demo/test/ and what I did here was plain search widget drag + drop in the Top Widget.

    dodYu.png

    was that how you have it?

    Thanks,
    Emil
  • Perfect. :D
    .top-widget {
        padding-top: 33px;
    }
    

    Thanks,
    Emil
  • Copy header.php from Responsive to Responsive Child Theme and add this in:
    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->
    

    and styles
    #header #search-box {
        clear:right;
        float:right;
        margin:20px -20px 0 0;
        width:30%;
    }
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    

    Emil
    kuszimy wrote:
    How to set search-box as a last position in header menu?

    I've already customized a few things with child template, but I don't know if I should alter the header menu or go deeper and override functions in functions.php file.

    =====
    Hi. Just had a quick look at a website (http://contactcustomerservice.co.uk/) in this thread and I was wondering about putting the search box aligned with the menu bar. I am using Responsive Child Theme. The problem is if I just use the Search Widget, I don't know how to adjust it to align like that.

    I am new to WP and this is my first theme. I'm also not an expert in HTML, scripts, etc. I just follow the instructions and I think I work it out somehow.

    I want to know where I can find the header.php to copy into Responsive Child Theme? And where do I begin to get that result?

    Thanks for your time,
    Arvin
  • Create a file called functions.php in the child theme.

    Add <?php right at the top of the file and then paste this code in.
    http://pastebin.com/yWFD4yBa
    Ulrich
  • grappler wrote:
    Create a file called functions.php in the child theme.

    Add <?php right at the top of the file and then paste this code in.
    http://pastebin.com/yWFD4yBa
    Ulrich

    This worked, however I have a number of different menu tabs and the search bar is too big and makes the bar wider and it doesn't look right (search bar is too long and the "Go" appears below it)

    Is there a code to add to this to make it auto fit or at least make it smaller and not so long?

    greatly appreciated! :)
  • I have tried both ways and i cant get it inline with my header bar. at the moment i added the lines to header and css however I cannot get it to display with 'go' on the same line or within the nav bar

    birminghamtenthire .com
  • code i have put in is:
    #header {
        background-color: white;
    }
    
    #header #search-box {
        clear:right;
        float:right;
        margin:20px -60px 0 0;
        width:30%;
    }
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    
  • If you guys still need assistance, can you please leave the URL for me?

    Thanks,
    Emil
    thekoolio wrote:
    code i have put in is:
    #header {
        background-color: white;
    }
    
    #header #search-box {
        clear:right;
        float:right;
        margin:20px -60px 0 0;
        width:30%;
    }
    
    #header #search-box #s {
    }
    
    .ie7 #header #search-box {
        margin-top:10px;
        text-align:right;
    }
    
  • Sorry I keep forgetting to add this css also.
    #searchform{
    margin:7px;
    }
    
    #searchform-item input[type="text"] {
        width: auto;
    }
    

    Ulrich
  • grappler wrote:
    Sorry I keep forgetting to add this css also.
    #searchform{
    margin:7px;
    }
    
    #searchform-item input[type="text"] {
        width: auto;
    }
    

    Ulrich

    Would this be to go along in addition with the functions code that you posted in pastebin? or should this be with the alt method that was posted by Emil of pasting that 2-part header and style code?
  • This is in addition to the functions code. It make sure the go button is on the same line and move the search bar in the middle of the bar.

    Ulrich
  • grappler wrote:
    This is in addition to the functions code. It make sure the go button is on the same line and move the search bar in the middle of the bar.

    Ulrich

    hmm i added that to the bottom of the style.css but it stayed the same. anything i may have missed?
  • hi guys, really appreciate the help. Unfortunately Ulrich I have put those two sets of code in now, and it does not work.... now the code you had in pastebin is just written at the top of my page :(

    www.birminghamtenthire.com
  • I keep getting the error on your link:
    Oops! Google Chrome could not find www.birminghamtenthire.com

    Emil
    thekoolio wrote:
    hi guys, really appreciate the help. Unfortunately Ulrich I have put those two sets of code in now, and it does not work.... now the code you had in pastebin is just written at the top of my page :(

    www.birminghamtenthire.com
  • try now, I had the wrong functions page in
  • nope like an idiot i gave you the wrong url its birminghamtenthire.co.uk
  • @thekoolio You dont need the first css. You can also remove the search bar from the top widget. If you already have a functions.php then you dont need the <?php before my code. Also set your reading settings to latest posts.

    Ulrich
  • OK I just got rid of
    #header #search-box {
    clear:right;
    float:right;
    margin:20px -20px 0 0;
    width:30%;
    }

    #header #search-box #s {
    }

    .ie7 #header #search-box {
    margin-top:10px;
    text-align:right;
    }

    I had to add <?php to the functions php to make the text move off the page. Now the search bar is stuck half way in the header... im so confused what to do now
  • any ideas yet? this is really bugging me and im spending hours trying to fix it
  • #search-box {
        width: auto;
    }
    

    Emil
    thekoolio wrote:
    any ideas yet? this is really bugging me and im spending hours trying to fix it
  • Where exactly do I put this code, as it does not seem to do anything in header or css. Ive tried all combination of css and php that yourself and ulrich have suggested and nothing is working. I dont want to be too much longer on your time
    #search-box {
        width: auto;
    }
    

    Emil
    thekoolio wrote:
    any ideas yet? this is really bugging me and im spending hours trying to fix it
  • style.css I tried it before posting and it works :)

    Emil
    thekoolio wrote:
    Where exactly do I put this code, as it does not seem to do anything in header or css. Ive tried all combination of css and php that yourself and ulrich have suggested and nothing is working. I dont want to be too much longer on your time
    #search-box {
        width: auto;
    }
    

    Emil
    thekoolio wrote:
    any ideas yet? this is really bugging me and im spending hours trying to fix it
  • Its still not working :( because so much was written on this topic Im wondering if two things have crossed paths, please can you go through the following and tell me if they are needed, and if so after which line to put them:
    #header {
    background-color: white;
    }

    #header #search-box {
    clear:right;
    float:right;
    margin:20px -60px 0 0;
    width:30%;
    }

    #header #search-box #s {
    }

    .ie7 #header #search-box {
    margin-top:10px;
    text-align:right;
    }

    <div id="search-box">
    <?php get_search_form(); ?>
    </div><!-- end of #search-box -->
    #searchform{
    margin:7px;
    }

    #searchform-item input[type="text"] {
    width: auto;
    }

    Plus what you just gave:
    #search-box {
    width: auto;
    }


    Hopefully we are coming to the end of this issue, thank you so much for your time, I will defo recommend you as your service is amazing
  • How about this:
    #header #search-box select, input[type="text"],
    #header #search-box  input[type="password"] {
        width: auto;
    }
    

    - or -
    #search-box select, input[type="text"],
    #search-box  input[type="password"] {
        width: auto;
    }
    

    Emil
    thekoolio wrote:
    Its still not working :( because so much was written on this topic Im wondering if two things have crossed paths, please can you go through the following and tell me if they are needed, and if so after which line to put them:
    #header {
    background-color: white;
    }

    #header #search-box {
    clear:right;
    float:right;
    margin:20px -60px 0 0;
    width:30%;
    }

    #header #search-box #s {
    }

    .ie7 #header #search-box {
    margin-top:10px;
    text-align:right;
    }

    <div id="search-box">
    <?php get_search_form(); ?>
    </div><!-- end of #search-box -->
    #searchform{
    margin:7px;
    }

    #searchform-item input[type="text"] {
    width: auto;
    }

    Plus what you just gave:
    #search-box {
    width: auto;
    }


    Hopefully we are coming to the end of this issue, thank you so much for your time, I will defo recommend you as your service is amazing
  • Guys,

    Firstly great theme and great support forum!

    This is my first Wordpress site and theme and after a lot of reading finally getting somewhere, but this forum has been a great help.

    Trying to get the search box in the middle of the menu bar like in Grappler's demo site but my menu bar is made higher by the search box and pulls the bar down.

    Tried both Grappler's and Emil's suggested CSS code but doesn't it.

    My site: www.greenedgeconsulting.co.uk

    Also trying to remove the feature image and fill the box with the feature text by making the title, subtitle and content full width as I want to put a lot of text into it. Any ideas for this?

    Many thanks,

    Simon
  • Now seems to be fine......very strange!

    Would still appreciated your advice on the feature section though.

    Many thanks,

    Simon
    Guys,

    Firstly great theme and great support forum!

    This is my first Wordpress site and theme and after a lot of reading finally getting somewhere, but this forum has been a great help.

    Trying to get the search box in the middle of the menu bar like in Grappler's demo site but my menu bar is made higher by the search box and pulls the bar down.

    Tried both Grappler's and Emil's suggested CSS code but doesn't it.

    My site: www.greenedgeconsulting.co.uk

    Also trying to remove the feature image and fill the box with the feature text by making the title, subtitle and content full width as I want to put a lot of text into it. Any ideas for this?

    Many thanks,

    Simon
This discussion has been closed.
All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

    Most Popular This Week