Template Tags/comments popup link

From 워드프레스(WORDPRESS) 한국어 위키

Jump to: navigation, search

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, and it does nothing if is_single() or is_page() is true (even when within The Loop).

Usage

%%% <?php comments_popup_link ('zero','one','more','CSSclass','none'); ?> %%%

Examples

Text Response for Number of Comments

Displays the comments popup link, using "No comments yet" for no comments, "1 comment so far" for one, "% comments so far (is that a lot?)" 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 so far', 
'% comments so far (is that a lot?)', '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() ) : ?>
<p>
<?php comments_popup_link( 'No comments yet', '1 comment', '% comments so far', 'comments-link', 'Comments are off for this post'); ?>
</p>
<?php endif; ?>

Parameters

zero 
(string) Text to display when there are no comments. Defaults to 'No Comments'.
one 
(string) Text to display when there is one comment. Defaults to '1 Comment'.
more 
(string) 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. Defaults to '% Comments'.
CSSclass 
(string) CSS (stylesheet) class for the link. This has no default value.
none 
(string) Text to display when comments are disabled. Defaults to 'Comments Off'.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author, comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link, comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link, comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Personal tools