WordPress.org

Support

Support » How-To and Troubleshooting » Search results not showing the correct number

Search results not showing the correct number

  • I’m having a problem with displaying the number of my search results:

    http://alexflint.net/tag/hummer

    If you visit the link, you’ll see “2 results found”, when actually there are more than 2. You can navigate to the previous entries and see more results.

    It seems to do this whenever more than 2 results are found. Can anyone fix my search.php code?

    <?php get_header(); ?>
    <div id="primary" class="single-post">
      <div class="inside">
        <div class="primary">
          <?php if (have_posts()) : ?>
          <h1>Search Results</h1>
          <ul class="dates">
            <?php while (have_posts()) : the_post(); ?>
            <li> <span class="date">
              <?php the_time('n.j.y') ?>
              </span> <a href="<?php the_permalink() ?>">
              <?php the_title(); ?>
              </a> |
              <?php the_category(', ') ?>
    <p />
    <?php the_excerpt_reloaded(50, 'all', 'content', FALSE); ?>
            </li>
            <?php $results++; ?>
            <?php endwhile; ?>
          </ul>
          <div class="navigation">
            <div class="left">
              <?php next_posts_link('&laquo; Previous Entries') ?>
            </div>
            <div class="right">
              <?php previous_posts_link('Next Entries &raquo;') ?>
            </div>
          </div>
          <?php else : ?>
          <h1>No posts found. Try a different search?</h1>
          <?php endif; ?>
        </div>
        <div class="secondary">
          <h2>Search</h2>
          <div class="featured">
            <p>You searched for &ldquo;<?php echo wp_specialchars($s, 1); ?>&rdquo;
              at
              <?php bloginfo('name'); ?>
              . There were
              <?php
    				if (!$results) echo "no results, better luck next time.";
    				elseif (1 == $results) echo "one result found. It must be your lucky day.";
    				else echo $results . " results found.";
    			?>
            </p>
          </div>
        </div>
        <div class="clear"></div>
      </div>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search results not showing the correct number’ is closed to new replies.
Skip to toolbar