When displaying how many comments a post has, WordPress determines the link to the comment section in two ways. If there is a comment, the anchor will be “#comments” (id=”comments”), if there are none, the anchor will be “#respond”, which leads directly to the comment form (“Leave A Reply”).
People who are interested in viewing the WordPress source code should look at the function comments_popup_link(), defined in wp-includes/comment-template.php on line 946ff (WordPress 3.0). The decision wether to use “#respond” or “#comments” is made on line 974ff.
In the WordPress template I use (cover-wp with some adjustments), the ID “comments” is used within the single.php or page.php and encloses the call of the comments.php. No problem here. Since that does not change and the single.php always exists, the anchor “#comments” should always remain existent.
The ID “respond” is being used in the comments.php… and there lies the problem with the Disqus integration: Disqus replaces the default comments.php with the one located at wp-content/plugins/disqus-comment-system/, and in that comments.php, there is neither a definition of an ID “comments” nor of an ID “respond”.
Therefore, the anchor “#comments” still worked on my site (as we now know, it is defined in single.php, not in comments.php). But since the Disqus comments.php was missing the “respond” ID, this anchor led to nowhere (every time a post had no comments).
The easy workaround is to add
<a name="respond" />
to the top of the Disqus comments.php (plugin version 2.33.8752: line 8 after the remarks) – now, both anchors will be found wether Disqus is enabled or not.
With other templates that define both IDs within the comments.php, none of both anchors would work with Disqus at this time, since those IDs are not defined within the Disqus comments.php, yet.
Therefore, you could just try to add
<a name="comments" />
<a name="respond" />
to the top of the Disqus comments.php.
I have already notified the Disqus helpdesk (thanks, Ryan!).
Excellent advice. I also had a broken “View Comments” link at the top of my WP single post pages, whether the post had comments or not. As per your suggestion, I added '<a rel=”nofollow”>' to comments.php, and now the link works.
Strangely, though, while on my index page the comment link always says “33 Comments” (or whatever number there are), on my single post page it still says “View Comments”, i.e., no count is displayed.
Anonymous
I could not find the solution anywhere. Thank you SO much for this post.
http://www.kyle-newman.com Kyle Newman
Well we’re up to version 2.61 and this still doesn’t seem to be fixed within Disqus! Thanks for providing the answer here. I just searched the Disqus forum and knowledgebase and couldn’t find an answer.
I tried inserting the code on line 8 as suggest but in the latest version that took you to below the comments section, so I put it on line 1 and that seemed to work. Thanks again for your article!
http://www.kyle-newman.com Kyle Newman
Just got sent another solution from Disqus. In the Disqus management panel, go to ‘advanced options’ (top-right) and then put a tick in the Comment Counts box – Output javascript in footer. This also fixed the problem for me.
Disqus And Broken Anchors
July 10th, 2010 | View Comments
If you have the feeling that the anchors to the comments and to the comment form are broken since you installed the Disqus Comment System plugin for WordPress, you might want to read along… maybe you’d also be interested in other posts about Disqus.
When displaying how many comments a post has, WordPress determines the link to the comment section in two ways. If there is a comment, the anchor will be “#comments” (id=”comments”), if there are none, the anchor will be “#respond”, which leads directly to the comment form (“Leave A Reply”).
People who are interested in viewing the WordPress source code should look at the function comments_popup_link(), defined in wp-includes/comment-template.php on line 946ff (WordPress 3.0). The decision wether to use “#respond” or “#comments” is made on line 974ff.
In the WordPress template I use (cover-wp with some adjustments), the ID “comments” is used within the single.php or page.php and encloses the call of the comments.php. No problem here. Since that does not change and the single.php always exists, the anchor “#comments” should always remain existent.
The ID “respond” is being used in the comments.php… and there lies the problem with the Disqus integration: Disqus replaces the default comments.php with the one located at wp-content/plugins/disqus-comment-system/, and in that comments.php, there is neither a definition of an ID “comments” nor of an ID “respond”.
Therefore, the anchor “#comments” still worked on my site (as we now know, it is defined in single.php, not in comments.php). But since the Disqus comments.php was missing the “respond” ID, this anchor led to nowhere (every time a post had no comments).
The easy workaround is to add
to the top of the Disqus comments.php (plugin version 2.33.8752: line 8 after the remarks) – now, both anchors will be found wether Disqus is enabled or not.
With other templates that define both IDs within the comments.php, none of both anchors would work with Disqus at this time, since those IDs are not defined within the Disqus comments.php, yet.
Therefore, you could just try to add
to the top of the Disqus comments.php.
I have already notified the Disqus helpdesk (thanks, Ryan!).
Filed under: WordPress Stuff · Tags: comments, disqus, howto, plugin, troubleshooting, wordpress