Support » Fixing WordPress » the_search_query(); not working for me

  • I am following a tutorial and I’ve added <h2>Search results for: <?php the_search_query(); ?></h2> in my code so that the relevant search terms are displayed but nothing happens. I’ve created a search.php file and copied my index.php code into it. I’ve reviewed the WordPress documentation and I’ve even downloaded the tutorial’s code and copied and pasted it into my file with no success. Please advise.

Viewing 4 replies - 1 through 4 (of 4 total)
  • what is the full code of your search.php?
    assuming that you added the code into search.php.

    what theme are you using?


    if (have_posts() ) : ?>
    <h2>Search results for: <?php the_search_query(); ?></h2>
    while ( have_posts() ) : the_post();
    else :
    echo ‘<p>No content found</p>’;

    I’m building from scratch…I’ve been following this tutorial: tut

    does the search work otherwise?

    do you use any plugins?

    Yes, the search works. I was just trying to figured out why the text won’t display. Some suggested I try <h2>Search results for: <?php echo the_search_query(); ?></h2> but that doesn’t work either.

    No, I’m not using any plugins

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘the_search_query(); not working for me’ is closed to new replies.