2

I've created a CPT for a site I'm working on at the moment called "campaigns". I've created a page which displays some content as well a custom loop which displays the most recent Campaign.

Everywhere else on the site I've used Disqus for commenting and I'd like to use Disqus here - but it doesn't seem to display. I've tried modifying the comments code to:

<?php $withcomments = "1"; comments_template(); ?>

but I get the regular comments form, rather than Disqus. Anyone any ideas how to work around that?

Thanks in advance!

8-2-11 - I've found a temporary workaround - which is to overwrite the comments.php file in the theme with the comments file from the plugin - but that means keeping the two in sync, so it would be great if I could find a better solution.

  • 1
    Probably this problem is related to the disqus plugin. Have you asked @ disqus if their plugin supports custom post types? – hakre Jan 21 '11 at 17:44
  • Thanks hakre - Disqus support said "we don't have any other reports of this behaviour". – Andrew Parker Feb 8 '11 at 16:23
  • I had the same problem with CPT. What you can do is using the embed version of the plugin on the CPT pages only : help.disqus.com/customer/portal/articles/… – Mr Washington Sep 5 '16 at 9:00
1

Are you registering your CPT with comments in supports array of register_post_type()?

From brief look at Disqus plugin code there is dsq_comments_template() function that checks for related stuff and it likely returns false if support for comments is not declared.

  • Thanks so much for taking a look - but yes, the CPT does have comments support enabled. – Andrew Parker Feb 8 '11 at 16:22
  • @Andrew Parker unfortunately I have no other ideas, probably your best option is going over code with debugger (or var_dump()) and trying to figure out why it doesn't load proper template. – Rarst Feb 8 '11 at 18:13
0

This is probably stupid and I'm sure you probably checked this beforehand... but it did the trick for me. Turns out, my users had unchecked the "allow comments" option in a lot of my custom posts, and I didn't go ahead and check that first.

Anyway, to debug this maybe you could temporarily modify the disqus plugin in file 'disqus.php' around line 671, you'll find the dsq_comments_template($value) function, which is the one that loads disqus instead of the regular comments.

What I did was check the conditions under which it doesn't load disqus, which are:

if ( !( is_singular() && ( have_comments() || 'open' == $post->comment_status ) ) ) {
    echo "sing?: ".is_singular()." have_comm?: ".have_comments().
            " open?:".$post->comment_status; // this was my modification ;)
    return;
}

if ( !dsq_is_installed() || !dsq_can_replace() ) {
    return $value;
}

when I realized $post->comment_status was the condition causing it to return, I checked all of my posts and cursed myself for not checking the obvious things first. Anyway, hope it helps!

  • Thanks WebMacheter - I did dig around that area of the plugin - I've got a feeling that the disqus swap-out doesn't respect the $withcomments option to trigger the substitution. I'll try your modification when I get a minute. – Andrew Parker Apr 29 '11 at 9:13

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