Showing trackbacks with Disqus
Currently 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, 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_trackbackstakes 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.