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'm using some code provided in an answer on here to calculate "post X of Y" and display pagination icons on single.php.

It works beautifully but it's causing problems displaying the_content();

On my local MAMP server it displays the content from the first post on every post, and on my web server it doesn't display the content at all.


My full code is below:

<div class="project-pagination">

    <?php

    // save current id to match later
    $current_project_id = $post->ID;

    $args = array(
        'post_type' => 'portfolio',
        'posts_per_page' => -1
    );
    $all_projects = new WP_Query( $args );

    ?>

    <ul>

    <?php

    while( $all_projects->have_posts() ) : $all_projects->the_post();

        // simple 'if' test to find the current post in the loop
        // note that current_post starts at zero, which is why we add 1 to it.
        // you can also output the_title, the_permalink, thumbnails, etc..

        $permalink = get_permalink();
        $projectnum = $all_projects->current_post+1;

        if( $post->ID == $current_project_id ){
            echo "<li class='project-page-btn-current'></li>";
        }else {
            echo "<li><a class='project-page-btn' href='".$permalink."'></a></li>";
        }

    endwhile;

    ?>
    </ul>

</div>

Any help would be appreciated!

Thank you

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try adding wp_reset_postdata(); after the endwhile; statement.

share|improve this answer
    
Q is where the pagination is implemented. Also the query itself, as it calls the class into the var shouldn't cause problems. –  kaiser Oct 11 '11 at 22:56
    
Worked perfectly! Thank you!! –  fxfuture Oct 11 '11 at 23:08

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.