WordPress.org

Support

Support » How-To and Troubleshooting » Trying to use is_search but not working

Trying to use is_search but not working

  • I used is_search to display “Search Results” on the page if someone searches something on my blog. This is the code I have in my archive.php file

    <?php /* If this is a search */ } elseif (is_search()) { ?>
    			<h2 class="archivetitle">Search Results</h2>

    However, I tried making a search and the title is not shown. You can see the problem here http://reviews.glumbo.com/?s=asus

    How can I fix this problem?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The link shows account suspended.

    AFAIK, when u don’t have template search.php, for search it uses template index.php not archive.php. My advice, create template search.php. Or if u still insist, just add that piece of code in index.php.

    If index.php:

    <?php if (is_search()) : ?>
       <h2 class="archivetitle">Search Results</h2>
    <?php endif; ?>

    If search.php:
    <h2 class="archivetitle">Search Results</h2>

    Just moved to a VPS. Let me try your suggestion and I’ll post here again

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to use is_search but not working’ is closed to new replies.