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


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

| 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

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.