0

I'm building a Blog theme in Wordpress and I want my input search box value to turn into placeholder value whenever I do any search. I have got success in it but whenever I'm putting any value in my search box the value is starting to filling form right instead of filling from left.

<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
<input type="search" class="search-field" placeholder="
        <?php if(get_search_query()){
            echo get_search_query();
        }else{
            echo esc_attr_x( 'Search anything', 'placeholder' );
        }
        ?>" value="" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
</label>
<input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" />
</form>

I'm new in WordPress theme development please help me any help will be appreciated.

There is the code below.

 <input type="search" class="search-field" placeholder="
    <?php if(get_search_query()){
        echo get_search_query();
    }else{
        echo esc_attr_x( 'Search anything', 'placeholder' );
    }
    ?>" value="" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
Rahul Kashyap
  • 967
  • 9
  • 25

1 Answers1

1

If I understand you right, it could be an issue of text-alignment.

How to align texts inside of an input?

try text-align: left; on CSS class "search-field"

Community
  • 1
  • 1
Avian
  • 101
  • 7
  • I have already used CSS but it is not working. The text which i'm putting after using CSS is working but after making a search it is not working. – Rahul Kashyap Jun 13 '15 at 14:44