0

I have custom template for my homepage. If i just put the_content(); to this template, nothing else, then it will display my text i entered in my admin panel in the editor. But if i have a different loop in my template, its display the content from an other post.

    <?php 
    query_posts( array(
            'post_type' => array(
            'movies'
            )
    ));
    if (have_posts()) : while (have_posts()) : the_post(); ?>
            asd
    <?php endwhile; endif; ?>

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
            <?php the_content(); ?>
    <?php endwhile; ?>

So the the_content(); part in the end is displaying the content from the previous loop. What should i do to fix this?

0

Try rewinding the Loop, via rewind_posts(), between the two loops?

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        asd
<?php endwhile; endif; ?>

<?php rewind_posts(); // REWIND THE LOOP! ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <?php the_content(); ?>
<?php endwhile; ?>
  • Thanks, but nothing changed. Edit: wp_reset_query() is working, thanks! – passatgt Aug 25 '11 at 14:10
  • @passatgt I rejected your edit, because it turns this answer into entirely different one. It would be better if you posted code that worked for you as separate answer. – Rarst Aug 25 '11 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.