WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Placeholder in SearchForm (4 posts)

  1. Skavenmight
    Member
    Posted 6 months ago #

    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>
  2. esmi
    Forum Moderator
    Posted 6 months ago #

    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>
  3. Skavenmight
    Member
    Posted 6 months ago #

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

  4. esmi
    Forum Moderator
    Posted 6 months ago #

    Glad I could help :-)

Reply

You must log in to post.

About this Topic