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' ) ?>" />