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?


1 Answer 1


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.

  • 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... Dec 2, 2011 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/… Dec 2, 2011 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... Dec 3, 2011 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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