Family Encyclopedia >> Electronics

How to Separate Trackbacks and Pingbacks from Comments in WordPress (2.7+)

Separating trackbacks and pingbacks from regular comments in WordPress creates a cleaner discussion section. WordPress 2.7 introduced a powerful new comment system with threaded replies, pagination, and more—but it required tweaks to core files. This proven method works for version 2.7 and later legacy setups. Note: Older versions are vulnerable to attacks like recent MySQL exploits; upgrade immediately if needed.

We discovered this reliable technique on Sivel.net, a go-to resource for WordPress developers.

Locate the main comments loop in your theme's comments.php file. It typically looks like this:

<?php if ( have_comments() ) : ?>
    <h3 id="comments"><?php comments_number('No Comments', '1 Comment', '% Comments' ); ?> on &ldquo;<?php the_title(); ?>&rdquo;</h3>
    <ol class="commentlist">
        <?php wp_list_comments(); ?>
    </ol>
<?php endif; ?>

Replace wp_list_comments(); with:

<?php wp_list_comments( array( 'type' => 'comment' ) ); ?>

Right after the closing </ol> tag (but still inside the if ( have_comments() ) block), add the pingbacks section:

<?php if ( ! empty( $comments_by_type['pings'] ) ) : ?>
    <h3>Trackbacks / Pingbacks</h3>
    <ol class="pinglist">
        <?php wp_list_comments( array( 'type' => 'pings', 'callback' => 'list_pings' ) ); ?>
    </ol>
<?php endif; ?>

Close the main if with <?php endif; ?> afterward. If no comments exist, only pingbacks will show.

To display pingbacks as a compact list (not full comment blocks), open your theme's functions.php and add this custom callback function:

function list_pings( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment;
    echo '<li ' . comment_class() . ' id="li-comment-' . get_comment_ID() . '"> ' . comment_author_link();
}

Finally, in comments.php, ensure the pingbacks <ol> uses li-comment- class for styling consistency.

Your complete updated loop should now resemble:

<?php if ( have_comments() ) : ?>
    <h3 id="comments"><?php comments_number('No Comments', '1 Comment', '% Comments' ); ?> on &ldquo;<?php the_title(); ?>&rdquo;</h3>
    <ol class="commentlist">
        <?php wp_list_comments( array( 'type' => 'comment' ) ); ?>
    </ol>
    <?php if ( ! empty( $comments_by_type['pings'] ) ) : ?>
        <h3>Trackbacks / Pingbacks</h3>
        <ol class="pinglist">
            <?php wp_list_comments( array( 'type' => 'pings', 'callback' => 'list_pings' ) ); ?>
        </ol>
    <?php endif; ?>
<?php endif; ?>
<?php if ( ! comments_open() ) : ?>
    <p>Comments are closed.</p>
<?php endif; ?>

Bonus: For precise comment counts excluding trackbacks/pingbacks, check our guide on accurate WordPress comment counting.

As seasoned WordPress developers, we've used this hack on production sites for years, ensuring organized, user-friendly comment areas.