Support » Fixing WordPress » Place the word "search" into the search box

  • Resolved wen.wainwright

    (@wenwainwright)


    Hi, I might be in the wrong forum and am happy to move if I am! I added a search box to the header of Twenty Twelve with code, not with a plugin or anything, and it works. I want to add the word “search” into the box rather than have a “submit button.” I’ve already removed the “submit button.” You can see the site here: http://marginalia.wendywainwright.com. I know that often you are supposed to include code in pastebin but have absolutely no idea which bit of code you would want to see! Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • You can copy paste this code in Text box :

    <input type="text" value="Search & Hit Enter" name="s" id="s" onfocus="if (this.value == 'Search & Hit Enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search and Click Enter';}" />

    Search and Click Enter will appear in the search box. You can change the words.

    Else use this :

    <form id="searchform" method="get" action="search.php">
    <input class="textbox" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
    <input type="submit" id="searchsubmit" value="" class="searchsubmit" />
    </form>

    These are old good HTML Forms actually…changing the ID (id='this value') will change the field’s and button’s text.

    Thanks! Which file should I post the basic html code into?

    Either hardcode (copy-paste) it in to template or use a Text Widget. Text Widget is better option obviously.

    I’d rather not use a widget if possible because the site is for someone else and I don’t want to worry about the widget author not updating the widget. I am using a child theme but am not clear as to exactly which template I should put the code in? The function.php?

    Moderator cubecolour

    (@numeeja)

    ɹoʇɐɹǝpoɯ

    The text widget is a standard feature of WordPress.

    Are you confused about the difference between the terms widget & plugin?

    I’m sure I’m confused. I did look it up and installed gabfire widget pack which does come with a search box…however I already have a search box and just want to add the text to it. I’m sorry this is so unclear to me but I appreciate your time.

    Moderator cubecolour

    (@numeeja)

    ɹoʇɐɹǝpoɯ

    The text widget Abhishek Ghosh mentioned is part of core WordPress – no additional plugins are needed.

    This is the correct place, right? http://codex.wordpress.org/WordPress_Widgets

    O.K. I read that but I still at least need to add a widget area to my header.php before I can use the textedit in the header, correct? (I am using a child theme.)

    @abhishek Ghosh – Thank you so much for you help 🙂 I was able to do it with the text widget and the second bit of code. I’m hoping I’ll be able to do it again after widgetizing an area. If someone else comes across this I drug the “text” widget (appearances –> widgets) to the main sidebar. I then copied the code above and pasted it into the text box area. I didn’t add a title because I put text in the box instead. The code above puts the word “search” in the box.

    <form id="searchform" method="get" action="search.php">
    <input class="textbox" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
    <input type="submit" id="searchsubmit" value="" class="searchsubmit" />
    </form>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    If you want the text inside the search form (box) to say something besides search then wherever you see the word “Search” with a capital S type your text instead. Do not change any of the quotations marks, etc. Apologies to those who are cringing at my super technical explanation!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Place the word "search" into the search box’ is closed to new replies.