Codex

Function Reference/comments popup link

Contents

Description

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.

Usage

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

Parameters

$zero
(string) (optional) Text to display when there are no comments.
Default: 'No Comments'
$one
(string) (optional) Text to display when there is one comment.
Default: '1 Comment'
$more
(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'
$css_class
(string) (optional) CSS (stylesheet) class for the link.
Default: None
$none
(string) (optional) Text to display when comments are disabled.
Default: 'Comments Off'

Examples

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.

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

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.

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

Source File

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

Related

cancel_comment_reply_link(), comment_author(), comment_author_email(), comment_author_email_link(), comment_author_IP(), comment_author_link(), comment_author_rss(), comment_author_url(), comment_author_url_link(), comment_class(), comment_date(), comment_excerpt(), comment_form_title(), comment_form(), comment_ID(), comment_id_fields(), comment_reply_link(), comment_text(), comment_text_rss(), comment_time(), comment_type(), comments_link, comments_number(), comments_open(), comments_popup_link(), comments_popup_script(), comments_rss_link(), get_avatar(), next_comments_link(), paginate_comments_links(), permalink_comments_rss(), previous_comments_link(), wp_list_comments()

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