Skip to main content

I have a wordpress site (build by someone else) in an apache environment which has been moved to our windows server, I have a strange issue where a simple PhP/WP loop is outputting the same result twice, even though there is one result for the query in the DB. Being a MVC/NET developer I'm not sure where to go next as I cant debug(step through) the code.

 <?php   if (have_posts()): while (have_posts()) : the_post();   $query = new WP_query('pagename=about');   $query->the_post();   /* Page Content */   echo '<h2 class="heading">';   the_title();   echo '</h2>';   echo '<div class="content">';   the_content();   echo '</div>';  ?>  <?php endwhile; ?>  <?php endif; ?> 

Any ideas of what could be causing this or how iI could set a loop limit?

Thanks, M

I have a wordpress site (build by someone else) in an apache environment which has been moved to our windows server, I have a strange issue where a simple PhP/WP loop is outputting the same result twice, even though there is one result for the query in the DB. Being a MVC/NET developer I'm not sure where to go next as I cant debug(step through) the code.

 <?php   if (have_posts()): while (have_posts()) : the_post();   $query = new WP_query('pagename=about');   $query->the_post();   /* Page Content */   echo '<h2 class="heading">';   the_title();   echo '</h2>';   echo '<div class="content">';   the_content();   echo '</div>';  ?>  <?php endwhile; ?>  <?php endif; ?> 

Any ideas of what could be causing this or how i could set a loop limit?

Thanks, M

I have a wordpress site (build by someone else) in an apache environment which has been moved to our windows server, I have a strange issue where a simple PhP/WP loop is outputting the same result twice, even though there is one result for the query in the DB. Being a MVC/NET developer I'm not sure where to go next as I cant debug(step through) the code.

<?php if (have_posts()): while (have_posts()) : the_post(); $query = new WP_query('pagename=about'); $query->the_post(); /* Page Content */ echo '<h2 class="heading">'; the_title(); echo '</h2>'; echo '<div class="content">'; the_content(); echo '</div>'; ?> <?php endwhile; ?> <?php endif; ?> 

Any ideas of what could be causing this or how I could set a loop limit?

Source Link
M T
  • 136
  • 1
  • 8

WP_Query outputting twice even though there is one result

I have a wordpress site (build by someone else) in an apache environment which has been moved to our windows server, I have a strange issue where a simple PhP/WP loop is outputting the same result twice, even though there is one result for the query in the DB. Being a MVC/NET developer I'm not sure where to go next as I cant debug(step through) the code.

 <?php if (have_posts()): while (have_posts()) : the_post(); $query = new WP_query('pagename=about'); $query->the_post(); /* Page Content */ echo '<h2 class="heading">'; the_title(); echo '</h2>'; echo '<div class="content">'; the_content(); echo '</div>'; ?> <?php endwhile; ?> <?php endif; ?> 

Any ideas of what could be causing this or how i could set a loop limit?

Thanks, M