WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Placeholder in SearchForm

[Resolved] Placeholder in SearchForm

  • First I must say that I’m not good at coding but I did manage to create this searchform.
    I made my own searchbar in searchform.php by tweaking it with CSS. But I noticed that I cannot add any text (Placeholder) inside the.
    Could anyone give me a hand and show me how to add a Placeholder text to my search bar? I have tried it in different ways but it seems more complex then I thought.. Thank you

    This is my code:

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div>
    
    <label class="screen-reader-text" for="s">
    </label>
            <input type="text" value="" name="s" id="s" />
            <input type="submit" id="searchsubmit" value="GO" />
        </div>
    </form>
Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    Try:

    <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
        <div>
    <label class="screen-reader-text" for="s">
    </label>
            <input type="text" value="" name="s" id="s"  placeholder="<?php esc_attr_e( 'Search'); ?>" />
            <input type="submit" id="searchsubmit" value="GO" />
        </div>
    </form>

    Perfect!! Exactly what I was looking for. 🙂
    Thanks a million!

    esmi

    @esmi

    Forum Moderator

    Glad I could help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Placeholder in SearchForm’ is closed to new replies.