Showing trackbacks with Disqus

http://media.disqus.com/images/global/disqus-logo.pngCurrently one of the limitations of using the otherwise great comments service Disqus is that it doesn’t allow you to display trackbacks/pingbacks.  Apparently this will be fixed in a future release of the Disqus WordPress plugin, but for now it’s not working.

The trackbacks you receive are still stored locally in your database, despite them not being displayed, so you can access them. However there isn’t a built-in way to access just the list of trackbacks. Trackbacks are stored as comments in the wp_comments table and are identified by a comment_type of either ‘trackback‘ or ‘pingback‘. (For our purposes here, there’s no real difference between the two. For more info on what the actual difference is, see this page) So, if you wanted to you could write up a bit of PHP that pulled all the trackbacks out of the database & displayed them on your blog, but for a lot of people this is a bit much.

If you look on this page (the FriendFeed Comments Plugin page), you can see a list of the trackbacks that page has received. It’s a very simple list, I’m not displaying the text snippet that usually comes with trackbacks, but that’s just personal preference. If you’d like to be able to display your trackbacks without having to worry about writing code yourself I’ve got a really simple plugin that lets you do this here. The plugin adds 2 functions, get_approved_trackbacks & trackbacks_templateget_approved_trackbacks takes the post id as an argument and returns a list of the trackbacks that have been approved (moderated) for that post. trackbacks_template is essentially an additional template tag to be used in the same way as comments_template() is used on the single.php template file.

So for example, if you wanted to display the trackbacks before the comments, download & install the plugin. Then open up the single.php template file for your site & find the line <?php comments_template(); ?>. Stick <?php trackbacks_template(); ?> on the line above it. This will display the trackbacks as an unordered list inside a div with the id "trackbackslist" with a h3 heading "Trackbacks" above the list. However if you’d like to style it differently, it will also look for a template file called trackbacks.php in your template folder. If it finds that it will use that to render the trackbacks.  This is what I’m doing here so as to not display the trackback text.  By default the plugin will display that too.

Obviously this is an advanced option, and only for those familiar with HTML & PHP.  For those people, the plugin provides a variable called $trackbacks which is an array of comment objects. The code that I’ve used to display the trackbacks by default is contained in a file called ‘trackbacks.php’ in the plugin folder, which you can copy into your template folder to use as a starting point for styling your own list.

Hopefully Disqus will sort out what it’s going to do with trackbacks, according to Daniel from Disqus it’s coming soon.  I’m pretty happy with their service, they’ve been really responsive to any support requests and they’ve had pretty solid uptime.  The lack of trackbacks isn’t really a big deal to me, but I do like to show who’s discussing my posts. As usual please leave comments / bug reports on the plugin’s page.

21 thoughts on “Showing trackbacks with Disqus

  1. I had seen that, and it works great. I’m just always hesitant to editplugins that I don’t control, especially with the WordPress Auto Updater.Inevitably It’d overwrite my changes & I wouldn’t notice for a week orsomething like that. I did that recently with another plugin that I had tomodifly slightly because it was conflicting with another.I just found myself writing the code for this into my single.php template &I thought “this is silly, what if I change templates?” so I wrote it as aplugin, and so I figured if it was useful to me, someone else might want touse it to :)

  2. I hear ya. In fact, I made extensive changes to a particular plugin and then auto-upgraded it without thinking a week later, so yes, you have a very valid point!I’m half-tempted to switch to your solution, but at this point I have a silly superstition that if I hold out with what I have, it will somehow bring the much-anticipated disqus update sooner.

  3. Pingback: Wicks Picks | The Personal Website of N. Todd Wickersty » Blog Archive » Wick’s Daily Picks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>