Disqus is a tremendous tool for handling the comments on your Wordpress website or blog, but the one thing I’ve been missing is a good way to display Recent Comments on the sidebar.
My latest project, the Nashville Sports Hub, is starting to spark some decent conversations, and I’d like to be able to feature that in the sidebar. Unfortunately, the standard WordPress Recent Comments widget doesn’t work especially well with Disqus. It also turns out that Disqus doesn’t offer widgets straight from their website, but the functionality is out there if you know how to tap into it.
Upon doing a search I found one site which laid out the steps for creating a recent comments widget on the Blogger platform, but what about WordPress?
Creating a Disqus Recent Comments Widget in WordPress
Step 1: Get your site’s Disqus ID
You’re going to need your Disqus Site ID later on, so log into Disqus and click the “Dashboard” link. On the left side, under the “Your Sites” heading, you’ll see all the sites for which you are the administrator, and next to the Site Name, the Site ID will be in parantheses, like this:
Step 2: Create a Text widget with script calling Disqus
Log into your WordPress dashboard, and head to the Widgets section. Drag a Text widget into the sidebar (or other area) where you would like to place it, and copy the following text into it:
Step 3: Customize the script for your site and preferences
Now it’s time to tweak that code to work for your site, taking those bits I’ve highlighted in red one at a time:
- Change the YOURSITEID to whatever the site ID is that you’re working with. Mine, for example, was “nashvillesportshub”.
- Set how many comments you’d like to appear by changing the number after “num_items=” in the text above. In this case, I’m using 3, but 5 is also commonly used.
- Do you want people’s Disqus avatars to appear, or stick with just text? To show the avatars, leave the number after “hide_avatars=” at 0, otherwise change it to 1 to show text only.
- How big should those avatars be? You may want to change the size based on the site format you’re working with, but try leaving “avatar_size=” to 32 first to see how that looks.
- How much text from each comment do you want to show? I like to show just enough to entice readers to click through and read more, so I have “excerpt_length=” set to 100 characters.
Feel free to twist the dials on those variables and see what works best for your site. If you have an active commenting community, you may want to show more recent comments, while those less actives ones may be best off displaying fewer (it may not look good to show something a month old, but you’re calling it “recent”).
So give this a shot on your own WordPress site, and make sure to swing by the Nashville Sports Hub and join the conversation!