WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am modifying the facebook comments plugin to my purposes. What I'd like to do is have it remove Wordpress native comments automatically if it is enabled- in fact what I'd really like it to do is use the Wordpress comments settings in the item itself and/or general settings to decide whether it should show or not.

Disqus works like this and its just how you would expect a comments replacement system to work by default- I think this plugin should work like that unless you tell it to do otherwise.

Does anyone have any ideas how disqus achieves this?


share|improve this question
up vote 1 down vote accepted

Most themes used comments_template to include their comment areas. It's completely full of filters, one of which is the include file (usually comments.php) that you can hijack to include a file from your plugin that contains all the stuff for facebook comments (or nothing if you just want to disable comments.


add_filter( 'comments_template', 'wpse35363_comments_template' );
function wpse35363_comments_template( $file )
    return plugin_dir_url( __FILE__ ) . 'path/to/your/file.php';

As far as general settings and per post settings, those are stored in wp_options and wp_postmeta respectively. Take a look at how the default comments compat file looks and you should get an idea about how you can do this in your plugin.

share|improve this answer
Thanks for the tips! Will report back ;) – David O'Sullivan Dec 2 '11 at 15:27
Actually thats not quite what I am after, as it is reliant on the template, I want it to be completely controlled by the plugin- like disqus. With the disqus plugin, it doesn't matter what template you are using, if disqus is enabled then wordpress native comments dont show up. This is what I want to know how to do... – David O'Sullivan Dec 2 '11 at 16:18
I promise you that this is the way to do it. In fact, it's the way Disqus does it. plugins.svn.wordpress.org/disqus-comment-system/trunk/… – chrisguitarguy Dec 2 '11 at 16:27
Ok got that sussed now, thanks very much! A couple of interesting observations. All I ended up doing was taking the content of the function fbcommentbox and added it into a seperate 'comments.php' file and changed the original function so it just had the line return dirname(FILE) . '/comments.php'; in it and added the line add_filter( 'comments_template', 'fbcommentbox'); after that. Intresting to note is that comments.php seems to get the variables- which I didn't expect, and also that you need to go via comments.php or it doesn't work... – David O'Sullivan Dec 3 '11 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.