• Resolved Philljc

    (@philljc)


    Hello. I am making a theme from scratch. I can find related articles on this problem but they are for older versions of WP.

    I am trying to include text in the search box, usually I put it in the “value” area, but this is taken up by the WP tag. How would I insert it into the following?

    <div id="search"><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
      <div>
        <input type="text" value="<?php the_search_query(); ?>" name="s" id="searchfield" onfocus="if (this.value==this.defaultValue) this.value='';" />
        <input type="image" src="wp-content/themes/shape/images/go.jpg" id="searchsubmit" value="Search" />
      </div>
    </form></div>

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php
    $searchtext = get_search_query();
    if($searchtext == ''){ $searchtext = 'Your text here'; }
    ?>
    <div id="search"><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
      <div>
        <input type="text" value="<?php echo $searchtext; ?>" name="s" id="searchfield" onfocus="if (this.value==this.defaultValue) this.value='';" />
        <input type="image" src="wp-content/themes/shape/images/go.jpg" id="searchsubmit" value="Search" />
      </div>
    </form></div>

    Thread Starter Philljc

    (@philljc)

    Perfect! Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Including text in search box’ is closed to new replies.