WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add some text in my blank search box for my blog.

My Blog: www.bornsquishy.com

Current searchform.php code:

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>">
    <input type="text" value="<?php the_search_query(); ?>" name="s">
   <input type="submit" value="Go">

I'm sure it's a simple fix, but I no absolutely nothing about php.

EDIT - Here's how I solved the problem:

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>">
   <input type="text" placeholder="Search My Site" value="<?php the_search_query(); ?>" name="s">
   <input type="submit" value="Go">
share|improve this question

closed as off topic by Wyck, kaiser, toscho Oct 4 '12 at 0:13

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

From the Codex Docs: The is_search() Conditional Tag checks if search result page archive is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.

<?php $search_box_term = is_search() ? get_search_query() : 'DEFAULT SEARCHBOX STRING'; ?>
<input type="text" value="<?php echo $search_box_term; ?>" name="s">

So this ↑ shows either DEFAULT SEARCHBOX STRING or the searched terms if you´re on a search results page.

EDIT: Here´s a filter that you can drop instead into your functions.php file:

function wpse50321_alter_search_form( $form )
    return '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" >
    <input type="text" value="' . ( is_search() ? get_search_query() : 'DEFAULT SEARCHBOX STRING' ) . '" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="'. esc_attr__('Go') .'" />
add_filter( 'get_search_form', 'wpse50321_alter_search_form', 99999 );
share|improve this answer
Thanks kaiser, but I'm still kinda lost. The php code I provided is what came with my theme, and I have the CSS already setup for it. Is there a way to incorporate the 'DEFAULT SEARCHBOX STRING' into the existing search box code? – BryGuy Apr 26 '12 at 14:58
This ↑ is adding a default text to your search box and replacing it with the search string on a search result page. The code isn´t changing css or anything else. Just the default value of the box. Add it and see what happens. – kaiser Apr 26 '12 at 15:04
I added the code and it created a second search box. – BryGuy Apr 26 '12 at 15:16
You have to replace your current search box with that. Else: You get two... EDIT See update. Now you got a filter also. – kaiser Apr 26 '12 at 15:21
When I remove the original code it removes my search box and leaves me with a search box with the "default..." text in it, but it doesn't do anything, and doesn't conform to my CSS. – BryGuy Apr 26 '12 at 15:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.