Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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; ?>
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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