Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/comments popup link


Displays a link to the comments popup window if comments_popup_script() is used, otherwise it displays a normal link to comments. This tag must be within The Loop or a comment loop.


 <?php comments_popup_link$zero$one$more$css_class$none ); ?> 


(string) (optional) Text to display when there are no comments.
Default: 'No Comments'
(string) (optional) Text to display when there is one comment.
Default: '1 Comment'
(string) (optional) Text to display when there are more than one comments. '%' is replaced by the number of comments, so '% so far' is displayed as "5 so far" when there are five comments.
Default: '% Comments'
(string) (optional) CSS (stylesheet) class for the link.
Default: None
(string) (optional) Text to display when comments are disabled.
Default: 'Comments Off'


Text Response for Number of Comments

Displays the comments popup link, using "No comments yet" for no comments, "1 comment" for one, "% comments" for more than one (% replaced by # of comments), and "Comments are off for this post" if commenting is disabled. Additionally, 'comments-link' is a custom CSS class for the link.

  comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments are off for this post');

Hide Comment Link When Comments Are Deactivated

Hides the paragraph element <p></p> that contains the comments_popup_link when comments are deactivated in the Write>Post screen. Good for those who want enable/disable comments post by post. Must be used in the loop.

if ( comments_open() ) :
  echo '<p>';
  comments_popup_link( 'No comments yet', '1 comment', '% comments', 'comments-link', 'Comments are off for this post');
  echo '</p>';

Load Different CSS classes according to Comment-condition

If you want to load different classes into comments_popup_link(), use the following:

$css_class = 'zero-comments';
$number    = (int) get_comments_number( get_the_ID() );

if ( 1 === $number )
    $css_class = 'one-comment';
elseif ( 1 < $number )
    $css_class = 'multiple-comments';

    __( 'Post a Comment', 'your-theme' ), 
    __( '1 Comment', 'your-theme' ), 
    __( '% Comments', 'your-theme' ),
    __( 'Comments are Closed', 'your-theme' )

Source File

comments_popup_link() is located in wp-includes/comment-template.php.


Comments Functions

See also index of Function Reference and index of Template Tags.