WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Remove search box [Twenty Eleven] (50 posts)

  1. jfg69
    Member
    Posted 3 years ago #

    Not finding anything in my search here, where can I find the code to comment out to remove the search box?

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Look for this code block in header.php:

    <?php
    // Has the text been hidden?
    if ( 'blank' == get_header_textcolor() ) :
    	?>
    	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
    	<?php get_search_form(); ?>
    	</div>
    	<?php
    else :
    	?>
    	<?php get_search_form(); ?>
    <?php endif; ?>

    Note: I strongly recommend making any changes in a Child Theme.

  3. jfg69
    Member
    Posted 3 years ago #

    Thanks Chip, I am working on a child theme, but cant seem to figure out how to get the changes I already made into the child theme..

    I would be copying the header.php into the child and editing that, correct?

  4. jfg69
    Member
    Posted 3 years ago #

    Searchbox gone, thanks!

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Yep; you got it!

  6. GeekMomMashup
    Member
    Posted 3 years ago #

    Howdy! What do I do with the header.php code to remove the search box in my child theme? What part should I delete? I have a separate search widget, and the default search box is hidden in my header image. Thanks for your help!

    Heather

  7. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Look for this bit, I think:

    <?php
    // Has the text been hidden?
    if ( 'blank' == get_header_textcolor() ) :
    	?>
    	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
    	<?php get_search_form(); ?>
    	</div>
    	<?php
    else :
    	?>
    	<?php get_search_form(); ?>
    <?php endif; ?>
  8. Altairelectronics
    Member
    Posted 3 years ago #

    Hi, I had the same question but do not know what to do with the code in order to change it. I have found where it's located under header.php, but what needs to be done in order to remove the search box completely. I was also wondering if taking this our will allow me to have a header across the whole theme or still up to where the search box was?

    Thanks in advance

  9. Altairelectronics
    Member
    Posted 3 years ago #

    Hi everyone, I was still wondering how to do this and haven't found the solution yet. Does anyone have some insight to share for this?

    Thanks

  10. chaddahlberg
    Member
    Posted 3 years ago #

    Altairelectronics - if you are looking to simply remove the search box in the header - comment out (or you can delete - but safer to comment out) the sections provided above in the header.php file and it will be gone. This what you're looking for?

    Chad

  11. MsCrow
    Member
    Posted 3 years ago #

    Hello, I also have the same question as Altair. I asked a colleague with an ipad to check as they were having menu wrapping issues. I have removed the search box following these instructions with my child theme. My colleague confirms that the wrapping has stopped and the menu is all on one line with no further menu editing needed.

    Thanks for the code assistance above Chip.

  12. Altairelectronics
    Member
    Posted 3 years ago #

    Thanks everyone, the problem is solved. I didn't know how to write the code for it but now it's all fixed and working smoothly.

  13. redi1
    Member
    Posted 2 years ago #

    Thanks Chip, very easy to follow.
    Now that the search box is gone. How do I place a banner in that position? Could you use html code that would normally used in text widget and place in header.php?

  14. strawberrytech
    Member
    Posted 2 years ago #

    I handled this a totally different way, and wonder if it is acceptable.

    I went to the "searchform.php" file and moved the "*/" following the comments at the top to the bottom, so that the header is calling an empty file.

    Is this totally a bad way of handling things?

  15. wldwil
    Member
    Posted 2 years ago #

    I read this three times now. So, if it is more safe to comment out would someone mind to explain what you put in your child theme to do so?

  16. quintont
    Member
    Posted 2 years ago #

    why not edit the css? :

    /* Search Form */
    #branding #searchform {
    	display: none;
    }
  17. wldwil
    Member
    Posted 2 years ago #

    Hi Quint,

    Are you saying to put this in the child theme?

    My understanding is that edits should be done in a child theme.

    Thanks,
    Bill

  18. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    to make changes (ie. commenting out) to a parent theme file such as header.php, you must copy that file from parent to child and then make the edits. The child theme's version will be used instead of the parent's (for theme files other than style.css and functions.php which behave differently)

    As far as css, you can simply write new rules in the child's style.css

  19. wldwil
    Member
    Posted 2 years ago #

    Maybe I have been unclear. The question is, how to comment out? I keep reading answers on this string saying to do it, but not how. At least with any specifics.

    Lets assume that a child theme is already in place. Lets assume Chips post is the code you want to comment out. What 'exactly' do you put in the child theme to comment it out?

    I appreciate your time and patience

  20. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    depends on what kind of code you are in.....

    for css:

    /*
    .bitofcode {
           rules: rules;
    }
    */

    for html

    <!-- <a href="blah blah"> blah </a> -->
    
    more code
    
    <!--
    <?php blah blah { ?>
       <blah>
    } ?>
    -->

    for php (as in, within a block of php code)

    <?php {
         code
         code
         // line of code to be ignored
         code
    ?>

    Google for more examples..... there are more

  21. coffee_king
    Member
    Posted 2 years ago #

    Does this remove it and then make it a useable space for more page links?
    Or is the space it frees up then unusable?

    My links below my header image sometimes move onto two lines and I'd like to free up a bit of space above so they always stay on the one line.

    Maybe its possible to move the search box over to the right by say 30 pixels?
    Anyone know how to do this?

  22. coffee_king
    Member
    Posted 2 years ago #

    For anyone wanting to know how to do this, I have just spent the last 30 minutes on it and now have it sorted.

    A) Make sure you are using a child header.php
    B) Go into your child header.php then highlight and delete all of the code recommended by Chip Bennett on the second post of this thread.
    C) Save your file.
    D) Upload your file.

    Thats it, your search box will now no longer exist.
    You can still use a search box widget as this just gets rid of the one sitting on the navigation section.

  23. Janell2
    Member
    Posted 2 years ago #

    Hi,
    It is always safer to COMMENT OUT your code rather than delete it. It will be easier to trouble shoot later.

    When you want to comment out code, use <!-- at the beginning of the code and
    --> at the end of the code, so it should look like this:
    <!--<?php
    // Has the text been hidden?
    if ( 'blank' == get_header_textcolor() ) :
    ?>
    <div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
    <?php get_search_form(); ?>
    </div>
    <?php
    else :
    ?>
    <?php get_search_form(); ?>
    <?php endif; ?>-->

    To just comment out one line only (to truly make a comment, you can use this:
    //this is just a comment
    However if it goes to a second line then each line you do not want to appear as code needs the // in front of it OR:
    <!--there are a lot of comments so just in case I am going to use the safer mode-->

    If you are commenting out css, use this:
    /*margin-top: 10px;*/

    However, in a child theme if you want to margin-top to be 0, you have to rewrite it to:
    margin-top: 0;

    However, in PHP commenting out code gets tricky, and a bit of research (more than I know since I am a programmer) would be in order.

    I like to upload the file to the child directory first, THEN comment it out or change the code and hit update. That way I can see in real time if the action worked and make changes accordingly.

  24. tammieearl
    Member
    Posted 2 years ago #

    Hello, I am trying to follow the directions posted here rather than starting a new question.

    I created my child theme, I commented out the search form, and now there's a big empty white space there. How do I get the title and subtitle to stop being all crunched up on the left and take that space instead?

  25. Stacy.Canion
    Member
    Posted 2 years ago #

    Anyone have any idea how to remove the entire "row" that the search bar was in? For instance, in twentyeleven there is basically a table row that contains the search bar. This thread was helpful in removing the search bar itself, but I still have this unsightly white bar running across the top of my site.

    Any ideas?

    See what I'm talking about at blog.canionphotography.net

    Thanks!

  26. Stacy.Canion
    Member
    Posted 2 years ago #

    Actually....

    I was trying to do something else and removed it myself! lol

    I removed this code :

    <hgroup>
    <h1 id="site-title"><span>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></span></h1>
    <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
    </hgroup>

    From the header.php in my child theme. It did the trick, if anyone else is interested.

  27. tammieearl
    Member
    Posted 2 years ago #

    Thank you Stacy, I truly appreciate your help but that didn't work for me. It removed the entire header text. I want to keep the text, just remove the white space where the search box once was. I want the text of the title and subtitle to take up the whole space at the top. My goal is to make this site very mobile friendly.

    Anyone else have an idea?

  28. danf87
    Member
    Posted 2 years ago #

    Thank you Chip Bennet you just save my hair from being pulled out. You are the man! Chip!

  29. Stacy.Canion
    Member
    Posted 2 years ago #

    Yes, sorry I am not using the header text so getting rid of that entire area was fine with me. I dont see a way to keep the text and get rid of the area.

  30. tammieearl
    Member
    Posted 2 years ago #

    Yes, Chip's fix does work, but it doesn't "free up" the area where the search box was previously located, once you remove it. That area is still there, a white empty box.

    Hey Stacy, you can also accomplish what you did to your site without messing with code. Just go to your dashboard, and on the lefthand side: appearance, then header, scroll down the right side (big part) and check NO for Display Text. The text will disappear, no coding required. You'll keep your pic.

Topic Closed

This topic has been closed to new replies.

About this Topic