Display Pingbacks on WordPress Posts with Disqus Comment System

Pingbacks and trackbacks are no longer supported in Disqus 2012.

Mentions via twitter are, but not pingbacks or trackbacks. The pingbacks are still being stored in the native WordPress database.
After a little searching and a little PHP, I managed to put together something that looks fairly decent. And it sits right above the Disqus comments. Or you could move it below the Disqus comments.


Disqus Pingbacks

Some of this code is taken from here: http://www.saphod.net. So I want to give him a shout out.
But I took his code and added some additional things.

Basically I added a few more columns in his select statement and then echo out comment_content, as well as using the substr and strrpos functions to make it shorter and only cut off the summary after a specified amount of characters and required blank space. I also select the ping date to echo out as well.

I always recommend backing up these files somewhere before editing them.

Step 1

Locate in your single.php file a line that looks like or is the same as this:

[php]<?php comments_template(); ?>[/php]

Step 2

Then insert this right above it. There might be a div in there too you want to dump this on top of.

[php]<?php DisplayPingTrackbacks(); ?>[/php]

Step 3

Go into your functions.php file or your theme’s function file and insert this at the bottom.

READ ALSO  How to Uninstall IE10 and Go Back to IE9

[php]function DisplayPingTrackbacks() {

// Do not do anything if Disqus is not installed
if(!dsq_is_installed()) return;

$current_post_ID = get_the_ID();

global $wpdb;

$sql = "SELECT comment_author_url, comment_date, comment_content, comment_author FROM $wpdb->comments WHERE comment_post_ID = $current_post_ID AND comment_approved = ‘1’ AND (comment_type = ‘pingback’ OR comment_type = ‘trackback’) ORDER BY comment_date ASC";

if ($post_pingtrackbacks = $wpdb->get_results($sql) ) {

$number_of_pingtrackbacks = count($post_pingtrackbacks);

if ($number_of_pingtrackbacks == 1) {
echo "<div id=’pingtrackback’><h3 style=’font-size:16px;margin-bottom:10px’>One Pingback/Trackback</h3><ul>";
} else {
echo "<div id=’pingtrackback’><h3 style=’font-size:16px;margin-bottom:10px’>" . $number_of_pingtrackbacks . " Pingbacks/Trackbacks</h3><ul>";

foreach ($post_pingtrackbacks as $post_pingtrackback) {

echo "<strong>";
echo date( ‘d F Y \a\t g:ma’, strtotime( $post_pingtrackback->comment_date ));
echo "</strong><br />";
$comment_summary = $post_pingtrackback->comment_content;
echo substr( $comment_summary, 0, strrpos( substr( $comment_summary, 0, 90), ‘ ‘ ) ) . ‘ …’;

echo "\n<li><a href=’";
echo $post_pingtrackback->comment_author_url;
echo "’>";
$author = $post_pingtrackback->comment_author;
echo html_entity_decode($author);
echo "</a>";
echo "</li>";
echo "</ul></div>";

And that’s it! You should now be able to see your pingbacks on your posts, alongside the Disqus Comment System. Enjoy!


Thomas Spear has taken all of this and released a WordPress plugin that will do this. Check it out! http://wordpress.org/extend/plugins/force-ping-display-with-disqus/

  • IslandNature

    Doesn’t seem to work on Firefox 16.0.2 on a Mac running 10.8 – pingbacks aren’t visible. Does work on Safari 6.0.2.

    • The code (PHP) itself shouldn’t matter across browsers, however I wonder if the (CSS) divs are being affected in how they display on Firefox on the Mac. This works for Firefox on PC, as that is where I originally tested it. I don’t have MAC to test on at the moment… Do you happen to have Firebug installed? I wonder if when you view the source code if the pingback is actually there if you do a CTRL+F (find)… just the div placement is messed up.

  • Radu Tanasescu

    This is awesome, it works and can be customised. Thank you, I’ve been looking for a way to make Disqus display pingbacks but this is so much better.

  • Talton

    Thanks for putting this together, Brian. It’s good to have this option available for people who still want to use pingbacks on their site, while using Disqus.

    • Your welcome. Happy we could find a way to use both together.

  • Thanks a lot, it works great.
    However, the hour format should be g:i, because “m” relates to months from 1 to 12.

  • Dream Secret

    Thank you!

  • Zilla of the Resistance

    I learned that this is now available as a plugin, and I when I tried it, it works! But can you please tell me how to make it so I can have the pingbacks show below the comments instead of above them? I need the “fore dummies” version. The plug in has an edit feature and when I clicked it, it looks like the code you have above, but I am not sure where or what to change to have the pings show beneath instead of above comments and I don’t want to screw it up. Thanks for this, BTW, it’s awesome to have pings on my stuff again.

    • Have to give props to Thomas (http://thomasspear.name/) for putting the plugin together. The plugin itself is simply a function that is attached to the comments template file. To show below comments, I would disable the plugin and simply use the code above, but for step #2, you will want to put it below “php comments_template()” in step #1. That will echo out your pings below the comments. Please make backups before trying this. Thanks

      • Zilla of the Resistance

        Thank you for the reply, Brian! I think I’ll leave it be with the pings on top, I am afraid I’ll wreck up something big time if I go messing with codes since I really don’t know what I’m doing. I am super happy to have my pings showing up again though! Thanks again, and thank you to Thomas, too!

        • Sure no problem 🙂 Yes I wouldn’t recommend editing the code if you aren’t familiar with PHP. You are already a step ahead of everyone else with pings showing on Disqus. Most people just gave up on showing them once they started using Disqus.

          • Zilla of the Resistance

            Well, I really like my pings, and I at least know how to use Google, which is how I eventually found your information.

  • fooduciary

    Got it to work with my Thesis theme. Thank you!!

    • Great, glad it worked for you! Some of us still love our pings 🙂

  • Thank for the the link! Glad we could help.

  • ThecaTTony

    Thanks Brian, it works great.

  • Momir Nikolajevic

    Hello Brian,
    I have one question.
    Is it possible to disable Disqus comment voting?

  • LD Jackson

    Thanks for this tip, Brian. I have it implemented on my website and put it under the comments. It seems that’s where it should be. It actually displays under the “More on this website” section.

    One question I would ask is this. Is it possible to modify the function to have it show just the link to the pingback, instead of the excerpt? That would make it much better on the page.

  • LD Jackson

    Actually, I figured it out. I just commented out the php section about the pingback content and now it displays the date and the link. Perfect, says me.

    • Sorry for the delay. Glad you got it working!

      • LD Jackson

        Hey, no problem. I’m glad I found your site through Google.

  • Thanks for the compliment!

  • Tae-Woo Noh

    Thanks. I have been chasing this solution. I just quit my journey 🙂

  • Paul Braren

    I (temporarily) tried the plugin approach, and it does work.

    But would there be some straight forward way to avoid displaying Trackbacks from my own site?

    In other words, display only off-site references to my site, not my own references to my own site from within my posts.


    • Have you tried to uncheck the “Allow trackbacks and pingbacks on this page.” checkbox under the discussion section?

      • Sounds promising, but I tried that on one article that had some trackbacks from myself, and it didn’t work, their still there, links from other articles on my site showing as trackbacks.

        I’ll reseach this some more, but if I do get it working, do you happen to know if there’s an easy way to globally do this, without having to turn off the checkbox under each post?

      • piyushp


  • Dominik

    Thx 🙂