WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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">


    // 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 );




    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>";




Any help would be appreciated!

Thank you

share|improve this question
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


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.