Viewing 8 replies - 1 through 8 (of 8 total)
  • Try looking in your searchform.php.

    Thread Starter christianharris

    (@christianharris)

    Weird, I can’t find this file anywhere. Which directory should it be in please?

    Thread Starter christianharris

    (@christianharris)

    It seems my theme doesn’t have a searchform.php…. I’ve searched the Web and it seems other themes are missing this form too

    Try:

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
    <div>
    <label for="s">Keyword(s)</label> <input class="text" type="text" value="<?php if(trim(wp_specialchars($s,1))!='') echo trim(wp_specialchars($s,1));else echo ' ';?>" name="s" id="s" />
    <input type="submit" class="submit" name="Submit" value="Search!" />
    </div>
    </form>

    Save the above as searchform.php within your theme’s folder.

    If you want to hide the input’s label, add:

    #searchform label {
    	position:absolute;
    	top:-1500px;
    	left:-1500px;
    }

    to your theme’s stylesheet.

    Thread Starter christianharris

    (@christianharris)

    Thank you so much Esmi. That worked a treat!

    You can remove the “Search for:” text by editing (WP version 2.8) wp-includes\general-template.php

    Line 125
    <div><label class="screen-reader-text" for="s">' . __('<!--Search for:-->') . '</label>

    I commented it out (as seen above) so it wouldn’t show. Hope that helps.

    TRUmsg

    (@applaudmedia)

    Better to hide the text using CSS such as:

    label.screen-reader-text {
    display: none;
    }

    or like esmi’s code. Otherwise you risk needing to edit the php file again whenever you update WP.

    What if I would like to edit the text instead of removing it?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Removing ‘Search For’ text from search box’ is closed to new replies.