WordPress.org

Ready to get started?Download WordPress

Forums

Pagination issue when Trackbacks & Comments are seperated (6 posts)

  1. Harish Chouhan
    Member
    Posted 1 year ago #

    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?

  2. MH Themes
    Member
    Posted 1 year ago #

    Hi,

    did you solve this?

    Regards
    Michael

  3. Harish Chouhan
    Member
    Posted 1 year ago #

    Hi Michael,

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

  4. MH Themes
    Member
    Posted 1 year ago #

    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";
  5. Harish Chouhan
    Member
    Posted 1 year ago #

    Thanks a tonne for sharing.

    Is this active on any website of yours?

  6. MH Themes
    Member
    Posted 1 year ago #

    Not yet - but soon! ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic