WordPress.org

Support

Support » How-To and Troubleshooting » Problem with loop on php5 only

Problem with loop on php5 only

  • mistycabal
    Member

    @mistycabal

    I need a bit of help here guys so if anyone can see why this might be causing a problem, please give your thoughts. I’m willing to try anything.

    Here’s the issue. The theme works perfect on php4, but as soon as I tried it on a host with php5 – I have a major problem in the search results page. Every result repeats 3 times.

    So you understand where the $cat is coming from, this is in the search.php grabbing a variable passed from the previous page:
    <?php $cat = $_GET["cityid"]; ?>

    This is the full loop found lower in the search.php:

    <?php if (have_posts()) : ?>
    <h2>Here's what we found when we searched for:</h2>
    <h3><?php the_search_query(); ?></h3>
      <div id="main-results">
    <ol>
    <?php while (have_posts()) : the_post(); ?>
    <?php if ( in_category($cat) ) { ?> <!-- checks to make sure we're searching selected category only -->
    <?php $url = get_post_meta($post->ID, 'url', $single = true); ?> <!-- get the meta value url -->
          <li><?php the_title(); ?> <span class="s-url"><a href="<?php echo $url; ?>" title="<?php the_title(); ?>"><?php echo $url; ?></a></li>
    <?php } else { ?>
    <div id="main-results">
    <h2>No results found. Try a different search?</h2>
    </div> <!-- /main-results -->
    <?php } ?>
    <?php endwhile; ?>
        </ol>
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    	</div> <!-- /main-results -->
    <?php else : ?>
    <div id="main-results">
    <h2>No results found. Try a different search?</h2>
    </div> <!-- /main-results -->
    <?php endif; ?>

    As I said, this works as expected on the server with PHP4. For some reason all my results are repeating 3 times each on the results page.

    Any ideas?

Viewing 1 replies (of 1 total)
  • mistycabal
    Member

    @mistycabal

    Found the problem. It’s always something simple eh ><

    Post revisions. They were showing up in the search results. Deleted and turned them off and it’s all good.

Viewing 1 replies (of 1 total)
  • The topic ‘Problem with loop on php5 only’ is closed to new replies.