Support » Fixing WordPress » Pagination issue when Trackbacks & Comments are seperated

  • Hello,

    I have trackbacks and comments separate in my theme.

    • For testing as per WordPress Theme review, I have set comment pagination with only 5 comments being displayed on each page.
    • For a post on which I have 2 trackbacks and 18 comments, on the first page, the 2 trackbacks are shown and 3 comments are shown
    • On subsequent pages, no trackbacks are shown and 5 comments are shown on each page

    Issue is:
    From the 2nd paginated pages onward, no trackbacks are shown but the heading “Trackback” is still displayed.
    I use this code to display the pings:

    /* Display Pings -------------------------------------------------------------*/
                if ( ! empty($comments_by_type['pings']) ) : // if there are pings ?>
    
                       <h3 class="pings-title"><?php _e('Trackbacks for this post', 'dreamsonline') ?></h3>
    
                        <ol class="pinglist">
                            <?php wp_list_comments( 'type=pings&callback=dreamsonline_list_pings' ); ?>
                        </ol>
    
                <?php endif; // end pings

    Is there a way, to make sure:

    1. remove the trackback heading from the 2nd page onwards
    2. Or keep trackback out of the pagination, so that on the main post page, 5 comments are shown and all the trackbacks?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    did you solve this?

    Regards
    Michael

    Hi Michael,

    Unfortunately not yet. There is no way to fix it.

    Hi,

    I found out that it breaks when you are using wp_list_comments twice, one for comments and one for pings.

    I did solve it by using wp_list_comments for the comments and for the pings I use a foreach loop. When you do it like this, the pagination works for the comments and the pings will be displayed without trouble.

    $pings = $comments_by_type['pings'];
    echo '<ol class="pinglist">' . "\n";
    foreach ($pings as $ping) {
       echo '<li class="pings">' . get_comment_author_link($ping) . '</li>' . "\n";
    }
    echo '</ol>' . "\n";

    Thanks a tonne for sharing.

    Is this active on any website of yours?

    Not yet – but soon! 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pagination issue when Trackbacks & Comments are seperated’ is closed to new replies.