DISQUS

The Disqus Blog: Turning off commenting on a single blog entry?

  • shinerweb · 9 months ago
    I think it 'should do' but there is a bug in the code.
    I just posted a similar thread in another group, but got the wrong code block in that group.

    Within the WordPress plugin code there is a function called dsq_comments_template

    I think the following line should be responsible for preventing the Disqus module from displaying on various pages:

    if ( ! (is_single() || is_page() || $withcomments) ) {
    return;
    }

    To me, that looks like it shouldn't print out Disqus, if it's a single page or has comments disabled.
    That's the line I believe to be broke, but I haven't had to time to dig deeper to find out exactly why.
    (I need more coffee if I have to go put my 'logic' head on).

    I'll dig deeper, but I think it's a bug 'somewhere' (in Disqus plugin or WP 2.7.1) rather than missing functionality.

    Regards

    Chris
  • Giannii · 9 months ago
    This is on our todo list and the only way you can disable posts and pages is
    here:
    http://disqus.com/admin/moderate/#/threads?t=ne...

    Giannii
    DISQUS
    Community Manager
    help@disqus.com
    http://twitter.com/giannii
  • Jake McKee · 9 months ago
    Yikes.

    That's a bit surprising... as it seems like that's an extremely core part of comments.

    Any idea what the ETA looks like? i.e. how big of a deal have you guys assessed this to be, thus what priority are you giving it?

    Thanks,
    Jake
  • shinerweb · 9 months ago
    Is that link correct above? That takes me to a list of my own comments...

    EDIT: Ah, now I see what you were suggesting... Ouch. Not a very clean way of doing it...

    And did you see my 'fix' below...
    Works for me..

    Chris
  • shinerweb · 9 months ago
    Ok, I've got it to obey the 'no comment' and 'page' by adding a new line.

    Edit the Disqus code, and locate

    if ( ! (is_single() || is_page() || $withcomments) ) {
    return;
    }

    Above the "if ( ! (is_single() || is_page() || $withcomments) ) {", add the following:

    if ( ('closed' == $post->comment_status) || ('page' == $post->post_type)){
    return;
    }

    Save the plugin and it should work.
    Don't forget to clear any cached pages if you have a cache plugin.

    I've not tested this fully yet, but it appears to work.
    I have a sneaky feeling the code

    if ( ! (is_single() || is_page() || $withcomments) ) {
    return;
    }

    is incorrect, (or cut and paste from a different plugin) as I can't see how it would work.
    I can't find reference to is_single() and is_page(). It sort of rings a MoveableType bell in my head, but I'm not certain on that.

    Try it and see if it works for you. I will ping Giannii and see what he says.
  • Jason · 9 months ago
    It seems like it should work to check for the WordPress post's comment status if you don't mind it not displaying existing Disqus comments that may have been left.

    is_single and is_page are descripted here: http://codex.wordpress.org/Conditional_Tags
  • Bob Torres · 7 months ago
    Thank you for this. It works perfectly.
  • shinerweb · 7 months ago
    Bob...

    Do you mean 'my hack' or their latest release.
  • Bob Torres · 7 months ago
    Your hack. :) Sorry for the confusion.
  • shinerweb · 8 months ago
    Just installed the latest WP Plugin module and it still doesn't obey is_single and is_page.
  • Virtualpro · 7 months ago
    Shinerweb, thanks for the hack this worked perfectly for a new contact me page

    Funny thing is that old pages that had comments disabled before Disqus was installed had no issues and were not displaying the disqus comment box.!!?!?! Bizzare

    Seems a fairly funadamental thing for the disqus plug-in, you've even given them the line they need to add in, can't be that difficult really.

    Thanks again
  • John Dugan · 5 months ago
    Shinerweb,

    You are an American hero.
  • Jake McKee · 4 months ago
    I'm STILL looking for this .... is it REALLY not fixed yet? This is getting to be silly, guy.
  • JFord · 4 months ago
    Hack it like Shiner suggests and it works like a dream.
  • Daniel Ha · 4 months ago
    Hey Jake, this works. Email me at daniel@disqus.com for personal help. We're phasing out these forums because they don't suit our support process well.

    Thanks for being patient.
  • Guest · 4 months ago
    ...
  • Daniel Ha · 4 months ago
    I am so sorry to hear that.
  • Daniel Ha · 4 months ago
    You don't say?