Enhanced Search Box
[resolved] The placeholder appear only on focus (4 posts)

  1. natostanco
    Posted 3 years ago #

    The default placeholder is shown until I click on the searchbar, than the customized placeholder is show, headway theme.


  2. Jupitercow
    Plugin Author

    Posted 3 years ago #

    I couldn't say for sure what is going on without seeing the code for theme.

    I imagine that the theme is already doing it's own stuff to manage the searchbox and this plugin might be incompatible.

  3. natostanco
    Posted 3 years ago #

    the theme function for the place holder is this:

    function headway_get_search_form($placeholder = null) {
    	if ( !$placeholder )
    		$placeholder = __('Type to search, then press enter', 'headway');
    	$placeholder = apply_filters('headway_search_form_placeholder', $placeholder);
    	$search_query = get_search_query();
    	$search_input_attributes = array(
    		'type' => 'text',
    		'class' => 'field',
    		'name' => 's',
    		'id' => 's'
    	/* Handle the placeholder and value */
    		//$search_input_attributes['placeholder'] = $placeholder;
    		$search_input_attributes['value'] = $search_query ? $search_query : $placeholder;
    		$search_input_attributes['onclick'] = 'if(this.value==\'' . $placeholder . '\')this.value=\'\';';
    		$search_input_attributes['onblur'] = 'if(this.value==\'\')this.value=\'' . $placeholder . '\';';
    	/* Turn the array into real HTML attributes */
    		$search_input_attributes = apply_filters('headway_search_input_attributes', $search_input_attributes);
    		$search_input_attributes_string = '';
    		foreach ( $search_input_attributes as $attribute => $value )
    			$search_input_attributes_string .= $attribute . '="' . $value . '" ';
    	return '
    		<form method="get" id="searchform" action="' . esc_url(home_url('/')) . '">
    			<label for="s" class="assistive-text">' . __('Search', 'headway') . '</label>
    			<input ' . trim($search_input_attributes_string) .' />
    			<input type="submit" class="submit" name="submit" id="searchsubmit" value="' . esc_attr__('Search', 'headway') . '" />

    I commented out the first two lines, the conditional to add the default theme placeholder, and enhanced search box works ok. See if you can fix the plugin so that there is no need to edit theme functions?

  4. Jupitercow
    Plugin Author

    Posted 3 years ago #

    Thanks for the update.

    This is a really basic plugin to add better placeholder functionality to the out-of-the-box searchbox. There really isn't a way to compensate for every single theme out there. They are all different and it depends on how the theme developer has decided to modify the searchbox. Some themes just won't be compatible with the plugin.

    I am glad you found a way to get it to work with your theme though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Enhanced Search Box
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.