• Resolved martywray

    (@martywray)


    Hi Ritchie,

    I’m currently using this code snippet to add a Search Bar to the Top Menu. Is there anyway to change the ‘Search..’ text as part of this?

    `function meso_add_custom_searchform() {
    return get_search_form();
    }
    add_action(‘bp_inside_top_nav’,’meso_add_custom_searchform’,20);

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Richie KS

    (@rkcorp)

    it use default wp get_search_form(), search google or wp codex for wp search_form filter.

    Thread Starter martywray

    (@martywray)

    Thanks Ritchie.

    I’ve added a searchform.php to my childtheme with the following code but can’t seem to get it to work in conjunction with the code in functions.php

    Any ideas?

    `<?php
    /**
    * default search form
    */
    ?>
    <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 echo esc_attr_x( ‘Search for people or places…’, ‘placeholder’ ) ?>” value=”<?php echo get_search_query() ?>” 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>

    Theme Author Richie KS

    (@rkcorp)

    should be like this

    function wpdocs_my_search_form( $form ) {
        $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" >
        <div><label class="screen-reader-text" for="s">' . __( 'Search for:' ) . '</label>
        <input type="text" value="' . get_search_query() . '" name="s" id="s" />
        <input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search' ) .'" />
        </div>
        </form>';
    
        return $form;
    }
    add_filter( 'get_search_form', 'wpdocs_my_search_form' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search Placeholder text’ is closed to new replies.