Mysterious WordPress Update Causes the Number of Comments Link to Include the Post Title

With the recent WordPress upgrade, the links that show how many comments were made to the blog posts have changed. My template was originally designed to only show the number of comments, but now it also includes the post title. Let's take a quick look at what's causing the issue and what can be done in response.


This website (CyberScorpion Bytes) is built with the self-hosted version of WordPress (aka At some point between version 4.1.5 and 4.2.2, WordPress has changed what it returns for the "number of comments" links. Instead of just getting the number, it also returns the post title (see Figure 1).

Screenshot showing how the post title was included in the number of comments link
Figure 1. Number of Comments Link

The Problem

To generate these links, I currently use the following code:

comments_popup_link('0 Comments');

Since I specified the first argument, all the posts with zero comments will have a link that says "0 Comments". Note that I didn't specify the second and third arguments which indicate how to handle posts with one or more comments. But the documentation for the comments_popup_link() function states that the arguments, when excluded, will result in WordPress using the default values.

However, the documentation says that the default values will be "1 Comment" if there's one comment or "% Comments" if there are more. Note that the "%" is replaced with the number of comments. So if a post has four comments, the link would say "4 Comments".

As far as I can tell, the documentation doesn't mention anything about the post title being included as part of the link.


To remove the post title from the "number of comments" links, you can simply specify the first three arguments of the comments_popup_link() function.

comments_popup_link('0 Comments', '1 Comment', '% Comments');

Final Thoughts

It should be mentioned that adding the post title to the "number of comments" links appears to be WordPress' way to make these links more accessible to visitors using assistive devices like screen readers. Note the <span> tag in the link below:

<a href="/2015-03/how-to-test-submissions-from-forms-that-use-the-post-method/#comments">4 Comments<span class="screen-reader-text"> on How to Test Submissions from Forms that Use the POST Method</span></a>

Instead of removing the text as described in this post, you could use the "screen-reader-text" class to hide the post title. The CSS code to do that can be found in the Twenty-Fifteen theme developed by WordPress.

Or you could consider using a different method for creating the "number of comments" links which utilizes the title attribute to make the links more accessible. For more information about the title attribute and accessibility, check out Supplementing link text with the title attribute.


There are currently no comments.

Leave a Comment