WordPress.org

Ready to get started?Download WordPress

Forums

Trying to use is_search but not working (4 posts)

  1. Matthew Hui
    Member
    Posted 3 years ago #

    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?

  2. giant slayer
    Member
    Posted 3 years ago #

    The link shows account suspended.

  3. Safirul Alredha
    Member
    Posted 3 years ago #

    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>

  4. Matthew Hui
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic