F
F
fsgdoterr2021-10-28 11:33:12
WordPress
fsgdoterr, 2021-10-28 11:33:12

WordPress why is the get_search_form filter not working?

I want to customize the search form using this code:

add_filter( 'get_search_form', function ( $form ) {

  $form = '
  <form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    <label class="screen-reader-text" for="s">Запрос для поиска:</label>
    <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Найти" />
  </form>';

    $form = '
    <div class="widget widget_search">
        <form id="searchform" method="get" role="search" action="' . home_url('/blog/') .'">
            <input class="text-search" type="text" onfocus="" placeholder="Search here..." value="' . get_search_query() . '">
            <input type="submit" class="submit-search" value="">
        </form>
    </div>';

    return $form;
} );

Nothing changes in the search widget in the sidebar, it only changes if you call the widget itself using the get_search_form () function, but I need it to work in the sidebar too, creating the formsearch.php file also did not help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question