Support » Fixing WordPress » Search results not showing the correct number

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

    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); ?>
            <?php $results++; ?>
            <?php endwhile; ?>
          <div class="navigation">
            <div class="left">
              <?php next_posts_link('&laquo; Previous Entries') ?>
            <div class="right">
              <?php previous_posts_link('Next Entries &raquo;') ?>
          <?php else : ?>
          <h1>No posts found. Try a different search?</h1>
          <?php endif; ?>
        <div class="secondary">
          <div class="featured">
            <p>You searched for &ldquo;<?php echo wp_specialchars($s, 1); ?>&rdquo;
              <?php bloginfo('name'); ?>
              . There were
    				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.";
        <div class="clear"></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.