Title: Initial text function
Last modified: August 30, 2016

---

# Initial text function

 *  Resolved [Duncan Michael-MacGregor](https://wordpress.org/support/users/duckonwater/)
 * (@duckonwater)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/initial-text-function/)
 * Hey there,
 * Fantastic plugin and just what I needed.
    Just one thing though, on our site 
   we have set up the search box so that it is just the box on its own (not enough
   space for button). To make it more user friendly it would be great to have some
   initial text in the box e.g. “Enter your search”.
 * Is there a function snippet you could provide that would do this?
 * I guess something like:
 * <input type=”text” value=”Search this site” onblur=”if(this.value == ”) {this.
   value = ‘Search this site’;}” onfocus=”if(this.value == ‘Search this site’) {
   this.value = ”;}” name=”s” id=”s” size=”25″ />
 * Thanks so much for this great plugin, it’s really helped us out!
 * Duncan.
 * [https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * (@joe_bopper)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/initial-text-function/#post-6766197)
 * Hi Duncan,
 * Sorry for not getting back to you sooner.
 * It sounds like what you’re after is the placeholder attribute for input elements.
   This is available by default as the _“Title Attribute”_ in the admin area, but
   only when the theme supports html5 for search forms.
 * To add theme support for html5 in search forms, put the following code in your
   theme’s _functions.php_ file:
 *     ```
       add_action( 'after_setup_theme', function(){
         add_theme_support( 'html5', array( 'search-form' ) );
       } );
       ```
   
 * This’ll let the placholder value be edited in the admin area. If, however, you
   want to have the value uneditable, add this to your _functions.php_ too:
 *     ```
       add_filter( 'bop_nav_search_the_attr_title', function( $ph ){
           $ph = __( 'YOUR FIXED PLACEHOLDER VALUE HERE', 'your-themes-text-domain' );
           return $ph;
       } );
       ```
   
 * Note: `__( 'string', 'text-domain' )` is WP’s gettext function which allows translations
   to be written of your strings for other languages.
 * Hope this helps.
 * Cheers,
    Joe
 * P.S. A [link](https://codex.wordpress.org/Function_Reference/add_theme_support)
   for more info on theme support.
 *  Thread Starter [Duncan Michael-MacGregor](https://wordpress.org/support/users/duckonwater/)
 * (@duckonwater)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/initial-text-function/#post-6766200)
 * Hey Joe,
 * No problem, thanks for getting back to me.
 * That’s bang on what I wanted! Thank you so much for that 🙂
    Keep us the awesome
   work!
 * Duncan.
 *  Plugin Author [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * (@joe_bopper)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/initial-text-function/#post-6766201)
 * Thanks, glad I could help.
 * Cheers,
    Joe

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Initial text function’ is closed to new replies.

 * ![](https://ps.w.org/bop-search-box-item-type-for-nav-menus/assets/icon-128x128.
   png?rev=1067133)
 * [Bop Search Box Item Type For Nav Menus](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/)
 * [Active Topics](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/reviews/)

## Tags

 * [Search Text](https://wordpress.org/support/topic-tag/search-text/)

 * 3 replies
 * 2 participants
 * Last reply from: [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/initial-text-function/#post-6766201)
 * Status: resolved