April 8, 2008
Hacking Disqus
If you're new here, please subscribe to my RSS feed. And follow me on twitter. Thanks for visiting!
No video for this post today. It’s just pure geekery that just cannot be made any less geeky or any more interesting by staring at my talking head.
Have I mentioned before that I <3 Disqus? I think maybe I have.
And a big thanks to the disqus guys for adding in a quick feature request I had that allowed me to pull my own disqus comments from every blog into my lifestream here on my homepage.
There are some other features that I’d like to see, and to work that out on my own, I’ve been doing some hacking and tweaking to get Disqus to do exactly what I want in Wordpress. Here’s what I’ve done so far and how you can implement it on your own.
If you do make these changes, keep a few things in mind:
- I did this in the beta version of the wordpress plugin.
- once they issue an update, these changes will be overwritten and if they haven’t addressed them, will need to be redone. That’s the life of a gangsta.
- proceed at your own risk.
Trackbacks
Disqus doesn’t have any support at all for trackbacks. But since Wordpress will still grab and store them in your comment database, you can still display those. Add the following code somewhere in your wp-plugins/disqus/comments.php script. Be sure to edit the one in the plugin dir. I put mine way down at the bottom.
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
DoFollow/NoFollow
Disqus posts all links in comments as dofollow links. (sans the rel=”nofollow”). That’s not that bad since Disqus has measures to prevent spammers. But it doesn’t stop the comment monkeys.
So I’ve been playing with a few different ways do put nofollow on some of the spammier comments while taking the opportunity to give dofollow back to the good guys.
Here’s what I did, again to comments.php. The bold code is what I added, I’ve included a little context so you can put it in yourself:
<ul id="dsq-comments">
<?php foreach ( $disqus_response['posts'] as $comment ) : ?>
<?php
//SCJ added check for rel=nofollow
if ($comment['points'] < 1 || $comment['user']['is_anonymous']) {
$follow = ' rel="nofollow" ';
} else {
$follow = "";
}
//SCJ end change
$profile_url = DISQUS_URL . '/people/' . $comment['user']['profile'] . '/';
?>
That sets the $follow var which I just slip into the website link here, down about 30 lines from the first change.
<?php if ( $comment['user']['url'] ) : ?>
<li><a href="<?php echo $comment['user']['url']; ?>"
target="_blank" <?php echo $follow?>>Website</a></li>
<?php endif ; ?>
Feature Requests for Disqus
While I’m at it, here are some feature requests…
- Incorporate real trackback support. I don’t think I care whether you just use Wordpresses trackback support like I did or try to incorporate it into your service. If you think you can do something about the spammers and scrapers, then by all means take it in. Maybe just allow an option to show trackbacks above or below the comments?
- Do something with the Dofollow/Nofollow. I’m pretty happy with the rules I set, which is to add in a nofollow for anonymous commenters and for comments that have been voted down. But something more sophisticated could surely be done and would be welcomed here.
- I want more notifications on blogs that I comment on. Right now, I think you send me an email if someone replies to one of my comments somewhere. But if there’s a conversation going on in a blog post that I’ve commented on, I want to know about it. Can I opt to get notified of any reply in a blog post that I’ve contributed to?
- I want to do more with Disqus, namely allow people who read my blog to START conversations, not just respond to the ones I start. I sent you guys at Disqus an email about this with more details. But I really think you guys are just scratching the surface here.
- I’m sure your lunches with Loic have you thinking about video comments, so I won’t waste a wish on that one.
What do you say, does anybody have other wishes? They’re hiring and surely need stuff for that Python hacker to do.




I did enjoy this post, but unfortunately I am already a subscriber….. Boy that line really jumps at ya…. lol
Thanks Scott!
Re: “I could rip off your comment form”
You can override it by setting these variables right before the javascript code for the comment form:
var disqus_title = “Whatever You Want”;
var disqus_url = “http://www.whateveryouwant.com”;
You can then pull it back using the URL if you go to http://jangro.disqus.com/?url=http://www.jangro.com/a/2008/04/08/hacking-disqus/
Definitely up for a round. any time!
Anyone else?
Scott,
I just noticed that with your trakcback hack, the links are “nofollowed”. If it was me, I would rather have my comments “noffolowed” but give credit to legitimate pingbacks. Can I remove the “nofollows” from trackbacks?
Thanks for setting me straight on this one ;).
It would almost have to be a two-step process - Type a title/Choose a category and take them to the page where they put in a comment….which would almost be better because otherwise you would lose the comment-tracking features if they were just “creating” a thread (FriendFeed, any followers through Disqus).
Daniel,
Since you are following this thread I though I would jump in with my own request…
The only reason I did not allow Disqus to manage comments on every single posts on my blog was because it would hide the exiting comments. I would like to see a feature that would import the exiting comments into Disqus unless of course there is away to show existent comments.
Thanks for the Trackback Hack. It will serve its purpose until that feature is added to Disqus proper.
I just added your trackback code. Good stuff, thanks!
Thanks for the referral!
thanks for the tip!
Glad to be helpful, Shey. Looking forward to seeing Disqus on your blog!
Indeed, this article is a great help.
1. Trackback is a must have
2. A simple but effective one
[...] Jangro’s trackback hack to the Disqus [...]
[...] [Update]: Disqusç›®å‰è¿˜ä¸æ”¯æŒå¯¹trackback的显示,Jungroåœ¨ä»–çš„æ–‡ç« ä¸æä¾›äº†ä¸€ä¸ªä¸´æ—¶çš„è§£å†³æ–¹æ³•: [...]
[...] the straw dropped that broken the camel’s back. This post: http://www.jangro.com/a/2008/04/08/hacking-disqus/. The community has started to hack (which in this world is good) Disqus, and if you read the [...]
[...] Hacking Disqus | Jangro.com (tags: blogging development comments disqus hacks) Posted in Daily Links | Like this Article? Subscribe var disqus_url = ‘http://www.mkoby.com/2008/06/04/links-for-2008-06-04/ ‘; var disqus_title = ‘links for 2008-06-04′; var disqus_message = ‘%0AWant to buy or sell a used BlackBerry? Read this first!!%0A** Posted using Viigo: Mobile RSS, Sports, Current Events and more ** Ever get the feeling that your used BlackBerry is not so fresh? Want to make sure the BlackBerry you’re looking to sell finds a good home without giving away any of your personal [...]%0A’; View the entire comment thread. Subscribe [...]
[...] Disqus announced support for trackbacks on the back-end and javascript plug-in today! This is great news, as up until now, us Disqus users had to be satisfied with a hack that was whipped up by Scott Jangro. [...]
Trackbacks are great and should be followed. They link together relevant articles and pass the juice that way.
Really great programming skills. And I agree with you dude, Trackbacks are great and should be followed.
great stuff here. i bow to your skills.
[...] you installed the nofollow Disqus hack that I created a few months ago, you’ll need to reimplement [...]
Wow. Really great programming skills on display here. Thanks for sharing them. Been looking for something similar for my blog and hopefully it works.
[...] undecided. All things balanced out, for now we keep Disqus on the blog - even though we might use a temporary hack to enable WordPress trackbacks. In my current estimate the social benefits and effects of using [...]
Great help! This has the Trackbacks showing up for me. Works as promised. Question: on your main blog page (i.e., not a single post page), where it shows the number of comments, should the number of trackbacks be included in this number also? General blog etiquette question. If yes, how do you get the trackbacks to count as comments on the main index page?
Im suprised you havent bought up the duplicate content issues… Disqus stores copies of all blog comments on their site, because they have now main comments on respective blogs indexable surely this is going to result in duplicate content issues with google and the major search engines… what are your views on this? comments are valuable source of keywords but surely if these are displayed on a larger, more popular site such as disqus their value is going to be lost?
“color_chart”,
My blog is pretty well established and gets some decent weight in google, so maybe if I had a newer blog, it could be a little concerning. But even so, I think there's enough difference between what's on the disqus pages and how it is organized and my blog that there isn't really a duplicate content concern for me.
Let me ask you an SEO question: Do you really get any benefit from commenting around with color_chart as your username? Really makes me wonder how genuine your comments are.
There is a very small seo value but not alot really… I put it there so people know where i come from… as for my comments being genuine then that is something for you to decide…
As for what you said about duplicate content… Everything ive read in researching the subject says that google (and as far as i know the other majors too) judge duplicate content on a phrase or keyword density basis which means it doesnt really matter where on the page it appears… I may be wrong because im no expert but surely its something worth investigating.
I didn't delete your comment and am talking to you, so clearly it seems to me that your comments are genuine. You're not in very good company with others who stuff their names in comments for SEO purposes.
I'm happy to have a real person giving real insights no matter what you call yourself.
The duplicate content thing is certainly worth investigating. I do know that if I search for certain exact phrases that appear in a comment, I may get only my disqus page as that result, not my blog. But, that's my disqus page, and hopefully if that person is interested in what the post was about, they'd come looking.
So on one hand, there may be duplicate content concerns, and on the other there could be SEO benefits in casting a broader, more powerful net.
At the end of the day, I can't say that there's been any significant change in search traffic with our without disqus, but I may be wrong in that perception.
Wow what a nice Feature Requests for Disqus with this codes. thanks for this info.
Big thanks to this very interesting and helpful post. I suggest that you make more post like this. You are really a big help to us.Thanks a lot. God bless you and more power…..
oh so this is possible to hack, good for hacker
Indeed , thanks great stuff here .
thanks for that code
should the number of trackbacks be included in this number also? General blog etiquette question. If yes, how do you get the trackbacks to count as comments on the main index page?
great hack thanks many time
this article is really really awesome.. and the author is great.. than you a lot
cool, nice job on hacking disqus. I never thought you could do so much thing with disqus.
Very good progamming skills. I really impress with those who have programming skills knowledge because with their skill , they can change oren to apple.
@inventory, i agree with you, those people can hack if they have the programming skills knowledge.
i salute to this programmer your my idol from now on.
I like this website. This website helped me with prayer learning. Good job. Thank you. Please provide more French prayers. Bye-bye.
Thanks for the code. It will serve its purpose until that feature is added to Disqus proper.
Cool site, keep up the good work!~The Gman
I think Disqus is going to be the next best thing in commenting. It’s great at stopping spam!
Excellent features you shared here