1

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?

1 Answer 1

2

Try this:

<?php $query = new WP_query('pagename=about'); if ($query->have_posts()): while ($query->have_posts()) : $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; ?> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.