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/2010/07/09/how-to-add-ping-trackbacks-when-using-disqus/ 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.

[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/

Incoming search terms:

  • view wordpress pingbacks
  • 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.

    • http://theitbros.com/ Brian Jackson

      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.

  • http://www.radutanasescu.ro/ 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.

    • http://theitbros.com/ Brian Jackson

      Great, glad we could help! :)

  • 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.

    • http://theitbros.com/ Brian Jackson

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

  • Pingback: Linux Admin's Journal · Disqus and Pingbacks()

  • http://www.flapane.com/ flapane

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

  • http://www.appgame.com/ Dream Secret

    Thank you!

    • http://theitbros.com/ Brian Jackson

      Your welcome!

  • Pingback: Dziura w Disqusie | Creamteam Branding & Advertising Design Studio()

  • http://marezilla.com/ 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.

    • http://theitbros.com/ Brian Jackson

      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

      • http://marezilla.com/ 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!

        • http://theitbros.com/ Brian Jackson

          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.

          • http://marezilla.com/ 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!!

    • http://theitbros.com/ Brian Jackson

      Great, glad it worked for you! Some of us still love our pings :)

  • Pingback: Visualizzare i pingbacks su Wordpress con Disqus - Lo Skyblog()

  • http://www.skyflash.it Cristian

    Thank you. Reposted in my blog :)

    • http://theitbros.com/ Brian Jackson

      Thank for the the link! Glad we could help.

  • http://www.elgatolibre.com.ar/ ThecaTTony

    Thanks Brian, it works great.

    • http://theitbros.com/ Brian Jackson

      Glad to hear it :) !

  • http://www.biztechconsultancy.com/magento-development.htm Magento Development

    wow !! superb. It’s working very greatly for me. I bookmarked your blog because in your blog, I found plenty of unique and innovative stuffs.

    • http://theitbros.com/ Brian Jackson

      Thanks for the compliment!

  • http://www.facebook.com/momir.nikolajevic Momir Nikolajevic

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

  • http://www.ldjackson.net/ 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.

  • http://www.ldjackson.net/ 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.

    • http://theitbros.com/ Brian Jackson

      Sorry for the delay. Glad you got it working!

      • http://www.ldjackson.net/ LD Jackson

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

  • http://gujustory.com Tae-Woo Noh

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

  • Pingback: Disqus에 트랙백/핑백 표기하는 워드프레스 플러그인 | Guju Story()

  • http://TinkerTry.com/about 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.


    • http://theitbros.com/ Brian Jackson

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

      • http://TinkerTry.com/about Paul Braren

        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


  • http://tekonaut.de/ Johannes

    Exactly what I was looking for. Thanks.

  • Micheal Clark

    Congratulations guys, quality information you have given!!!facebook likes

  • http://www.mobilelifeblog.de Dominik

    Thx :)

  • cindy_dy0121

    Thank you for the information. You have a very good article. I found it informative and useful. Keep up the good work and God bless!


  • http://www.andybarratt.co.uk/ A. P. Barratt

    Thanks so much for this! Until yesterday, I didn’t know Pingbacks existed. My new theme was showing them as recent comments. It was Disqus themselves who told me what was going on. I found this post and now I’m sorted. Even got it all styled up to fit with my theme. Thanks so much!

  • henrysaw37

    Hello everyone and to the admin of disqus. I made a new account for disqus because I was block by the admin. It is my 5th times making a new account just for this site. I hope the disqus team will not block me again. Thank you.


  • bra tape

    Thanks for sharing
    this useful information! Hope that you will continue with us.

    bra tape

  • http://www.gwebpro.com/ G Web Pro

    Its not good to activate pingback system in disqus. It can create huge amount of trackback spam link. Recently I have seen some blogs which have lots of trackback spam link. These links can not be seen visually on webpage, but if you go to source code all the spam link can be visible.

    I never recommend to active picgback on disqus commenting..

    G Web Pro

  • raju kr

    EMTV is Papua New Guinea’s Best Article news provider in countries. This channel is one of the most trusted sources of PNG news, PNG Local news, PNG Videos, PNG news Article & many more.
    PNG Business News