Articles Comments

Marco Luthe Online! » WordPress Stuff » Disqus And Broken Anchors

Disqus And Broken Anchors

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

<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!).

Filed under: WordPress Stuff · Tags: , , , , ,

blog comments powered by Disqus