Many website owners use Disqus for comment moderation and hosting due to its robustness and spam filtration capabilities. However, a common limitation of Disqus is that it does not display native trackbacks or pingbacks.

If your site receives trackbacks from other blogs, these trackbacks are still recorded and stored locally in your database—they are simply ignored by the Disqus embed script. For site builders who want to show who is discussing their posts elsewhere on the web, this guide outlines a technical solution to retrieve and render those local trackbacks.

Database Structure: Comments vs. Trackbacks

In WordPress, trackbacks and pingbacks are stored in the same database table as standard comments: wp_comments. They are distinguished from standard comments by their comment_type value:

  • Trackbacks: comment_type is set to 'trackback'
  • Pingbacks: comment_type is set to 'pingback'

For rendering purposes, trackbacks and pingbacks are functionally identical. We can query the database directly to retrieve only these types for a specific post.

Direct Database Query

To display trackbacks, you must query the database to fetch approved entries of type 'trackback' or 'pingback' associated with the current post ID.

Below is a custom PHP helper function that executes this query and returns an array of trackback objects:

/**
 * Retrieve approved trackbacks and pingbacks for a given post.
 *
 * @param int $post_id The ID of the post.
 * @return array Array of approved trackback comment objects.
 */
function get_approved_trackbacks($post_id) {
    global $wpdb;

    $query = $wpdb->prepare("
        SELECT * 
        FROM $wpdb->comments 
        WHERE comment_post_ID = %d 
          AND comment_approved = '1' 
          AND (comment_type = 'trackback' OR comment_type = 'pingback')
        ORDER BY comment_date ASC
    ", $post_id);

    return $wpdb->get_results($query);
}

Creating a Reusable Template

Once you have retrieved the trackbacks, you can render them as an HTML list. It is best practice to keep this markup in a separate template file, such as trackbacks.php, within your theme folder.

Here is a clean implementation template for trackbacks.php:

<?php
// trackbacks.php
$trackbacks = get_approved_trackbacks(get_the_ID());

if (!empty($trackbacks)) : ?>
    <div id="trackbacks-container" class="trackbacks-list">
        <h3>Trackbacks</h3>
        <ul>
            <?php foreach ($trackbacks as $trackback) : ?>
                <li id="comment-<?php echo $trackback->comment_ID; ?>">
                    <a href="<?php echo esc_url($trackback->comment_author_url); ?>" rel="external nofollow" class="trackback-link">
                        <?php echo esc_html($trackback->comment_author); ?>
                    </a>
                    <span class="trackback-date">
                        on <?php echo date('F j, Y', strtotime($trackback->comment_date)); ?>
                    </span>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
<?php endif; ?>

Note: In the implementation above, we display only the author link and date of the trackback. Many builders prefer to omit the content snippet (comment_content) to prevent spam links and keep the design minimal.

Integrating with your Post Layout

To display trackbacks on your single post pages, open your theme’s single.php template file. Locate the call to comments_template() (which is where Disqus renders) and include your custom trackbacks template file directly above it:

// single.php
// ... post content ...

// Include trackbacks list if any exist
if (file_exists(get_template_directory() . '/trackbacks.php')) {
    include(get_template_directory() . '/trackbacks.php');
}

// Render the standard Disqus/WordPress comment template
comments_template();

By decoupling trackbacks from standard comments, you can retain the benefits of Disqus’s hosted comment threads while preserving and displaying the organic peer discussions occurring across the blogosphere.