WordPress comments_popup_link() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

In WordPress, comments_popup_link() prints a link to the comments of the current post. The link text shows the number of comments.

If there are no comments, the link goes to the comment form (#respond). If comments are closed, it prints plain text instead of a link.

Syntax

Call it with no arguments for the defaults, or set the texts and a CSS class.

WordPress
comments_popup_link();
comments_popup_link( 'Leave a comment', '1 Comment', '% Comments', 'comments-link', 'Comments are off' );
CallWhat it does
comments_popup_link()Prints a link with default texts.
comments_popup_link( 'Leave a comment', '1 Comment', '% Comments' )Prints a link with your own texts.
comments_popup_link( '', '', '', 'comments-link' )Adds a CSS class to the link.

Use it in the post loop. The word popup is old. The link does not open a popup window.

Full declaration
WordPress
comments_popup_link( string|false $zero = false, string|false $one = false, string|false $more = false, string $css_class = '', string|false $none = false ): void

Parameters

ParameterDescription
$zeroOptional. Text when there are no comments.
$oneOptional. Text when there is one comment.
$moreOptional. Text when there are more comments. Use % for the number.
$css_classOptional. A CSS class for the link. Default is empty.
$noneOptional. Text when comments are turned off.

Return Value

Return ValueDescription
voidNothing is returned. The function prints a link or a short text.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Default link

Print the link with default text.

WordPress
<p class="meta"><?php comments_popup_link(); ?></p>

How It Works

  1. The post has three comments, so the link goes to #comments.
  2. The text shows the number.
  3. A hidden screen reader text names the post.

Example 2 — Custom text

Use your own texts for each case.

WordPress
<?php comments_popup_link( 'Leave a comment', '1 Comment', '% Comments', 'comments-link', 'Comments are off' ); ?>

How It Works

  1. The five arguments are zero, one, more, class, and none.
  2. This output is for a post with three comments.
  3. With no comments the link goes to #respond.

Example 3 — When comments are closed

See the output when comments are off and there are none.

WordPress
<?php comments_popup_link( 'Leave a comment', '1 Comment', '% Comments', 'comments-link', 'Comments are off' ); ?>

How It Works

  1. There are no comments and comments are closed.
  2. WordPress prints a span with the last text.
  3. No link is printed because there is nothing to open.

Frequently Asked Questions

It prints a link to the comments of the current post, with the comment count as text.
No. The name is old. It is a normal link.
To the comments area, or to the comment form when there are no comments.
It prints the text you set in the last argument, without a link.
comments_number() prints only text. comments_popup_link() prints a link around the text.

Next: get_avatar()

Return the HTML img tag of a user or commenter avatar.

get_avatar() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful