Home / search / Show search query in search box and query in results page
  • How to Show search query in search box and query in results page

    show-search-query-in-search-box-and-query-in-results-page

    Adding these snippets to your search template will display the search query on the results page and the search query within the search box on the results page.

    ( click code to copy )

    wordpress snippet : PHP - results in search box

    <>
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
      <div>
        <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
        <input type="submit" id="searchsubmit" value="Search" />
      </div>
    </form>
    
    ( click code to copy )

    wordpress snippet : PHP - results query

    <>
    <p>You searched for " <?php the_search_query() ?> ". Here are the results:</p>
    

    ( WordPress codex functions, hooks, in this snippet. )

    bloginfo, query,