Using different comment system?
-
For Disqus particularly? Hmm… I don’t know if this is possible. I believe the Disqus plugin hooks in to the comments_template() template tag and overrides WP’s default implementation with its own.
You could try coding something into your theme to use comment function calls in the page.php template without calling comments_template()… might work, but I dunno. Something that says if within a set of page IDs use the custom solution, otherwise use comments_template().
I hope this helps!
Could you perhaps elaborate a little bit? How do I set the “custom solution” to be WordPress’ default comment system?
Actually, it turns out to be really easy to do that.
The Disqus plugin works by adding a filter like so:
add_filter('comments_template', 'dsq_comments_template');So you hook into something before the
comments_templatelikethe_contentand remove that filter but only for a specific post or page ID (IDs are unique). So if you wanted to use Disqus for everything but disable it for page ID123it’s justadd_filter( 'the_content' , 'mh_disable_disqus' ); function mh_disable_disqus( $content ) { $id = get_the_ID(); if( $id == 123 ) { remove_filter('comments_template', 'dsq_comments_template'); } return $content; }You can use other tests instead of the ID such as
has_tag( 'No Disqus' )to handle Disqus commenting or not.Do I just add that code into my functions? Don’t I have to call it in my page/post.php files?
“So you hook into something before the comments_template like the_content and remove that filter but only for a specific post or page ID (IDs are unique).”
Sorry, I’m more of a PHP noob, how would I hook into that?
Sorry, I’m more of a PHP noob, how would I hook into that?
See that line that has
add_filter? That hooks into the WordPress loop when the post or page content is being processed viathe_contentfilter.There are lots of places to do that hook, I just picked it because
the_contentget’s displayed before thecomment_template. It’s a good place to remove any filters or functions that effect the comment section for that post or page.You can put that code in your theme’s
functions.phpfile or create it as a plugin like so.Copy that text into
wp-content/plugins/selectively-disable-disqus.phpand activate it in your dashboard.Using it as a plugin is safer. If something goes wrong, just delete the plugin file.
You will need to know what the ID of the page or post that you want to exclude Disqus comments from is. It’s probably not
123. 😉
The topic ‘Using different comment system?’ is closed to new replies.
(@futurepocket)
14 years, 1 month ago
I am currently using Disqus on my blog.. I wanted to know how I could configure this on a page to page basis.
I want my whole blog to use Disqus except for a group of pages to use the default WordPress comment system. Is this possible? Thanks.