Wordpress Comment Template Tags

  • Share this Post on Digg
  • Share this Post on Twitter
  • Share this Post on Design Float
  • Share this Post on Delicious

Jan 20th, 2009 Wordpress 0 Comment

Stumble Wordpress Comment Template Tags

The following is a useful reference guide for Wordpress theme development, based upon the Comment Template Tag section of the Wordpress.org Codex.

Comment Template Tags

Comment Count
Label: comments_number();
Code: <?php comments_number(’zero’, ‘one’, ‘more’, ‘number’); ?>

Displays the total number of comments, Trackbacks, and Pingbacks for a post. This tag must be within The Loop.

Link to Post Comments
Label: comments_link();
Code: <?php comments_link(); ?>

Much like an RSS feed for your WordPress blog, this feature will display a link to the RSS feed for a given post’s comments. By implementing the feature, your readers will be able to track the comment thread for a given post, perhaps encouraging them to stay connected to the conversation.

JavaScript for Pop-Up Window
Label: comments_popup_script();
Code: <?php comments_popup_script(width, height); ?>

Outputs the JavaScript code for a comments popup window. Used in tandem with comments_popup_link(), this tag can be used anywhere within a template, though is typically placed within the <head> portion of a page.

Link to Pop-Up Window
Label: comments_popup_script();
Code: <?php comments_popup_link (’zero’,'one’,'more’,'CSSclass’,'none’); ?>
 
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).

Comment ID
Label: comment_ID();
Code: <?php comment_ID(); ?>

Displays the comment author name; that is, the one supplied by the commenter. If no name is provided (and “User must fill out name and email” is not enabled under Discussion Options), WordPress will assign “Anonymous” as comment author. This tag must be within The Loop, or a comment loop.

IP Address of Comment Author
Label: comment_author_IP();
Code: <?php comment_author_IP(); ?>

Displays the comment author’s IP address. This tag must be within The Loop, or a comment loop.

Email of Comment Author
Label: comment_author_email();
Code: <?php comment_author_email(); ?>

Displays the comment author’s email address, not linked. An email address must be provided if “User must fill out name and email” is enabled under Discussion Options. This tag must be within The Loop, or a comment loop.

Website URL of Comment Author
Label: comment_author_url();
Code: <?php comment_author_url(); ?>

Displays the comment author’s URL (usually their web site), not linked. This tag must be within The Loop, or a comment loop.

Mailto Link to Comment Author
Label: comment_author_email_link();
Code: <?php comment_author_email_link(’linktext’, ‘before’, ‘after’); ?>

Displays the comment author’s email address, as a mailto link. An email address must be provided if “User must fill out name and email” is enabled under Discussion Options. This tag must be within The Loop, or a comment loop.

Link to Website URL of Comment Author
Label: comment_author_link();
Code: <?php comment_author_link(); ?>

Displays the comment author’s name linked to his/her URL, if one was provided. This tag must be within The Loop, or a comment loop.

Type of Comment
Label: comment_type();
Code: <?php comment_type(’comment’, ‘trackback’, ‘pingback’); ?>

Displays the type of comment (regular comment, Trackback or Pingback) a comment entry is. This tag must be within The Loop, or a comment loop.

Comment Text
Label: comment_text();
Code: <?php comment_text(); ?>

Displays the time a comment was posted. This tag must be within The Loop, or a comment loop.

Comment Author’s Name Formatted for RSS
Label: comment_author_rss();
Code: <?php comment_author_rss(); ?>
 
Displays the comment author’s name formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop, or a comment loop.

Comment Text Formatted for RSS
Label: comment_text_rss();
Code: <?php comment_text_rss(); ?>

Displays the text of a comment formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop, or a comment loop.

Comment Link Formatted for RSS
Label: comment_link_rss();
Code: <?php comment_link_rss(); ?>

Displays the URL to an entry’s comments formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop, or a comment loop.

Comment Permalink Formatted for RSS
Label: permalink_comments_rss();
Code: <?php permalink_comments_rss(); ?>

Displays the permalink to the post to which a comment belongs, formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop, or a comment loop.

No related posts.

Leave a Reply to "Wordpress Comment Template Tags"

Have an Avatar? - Register one now!
Liked the post? - Subscribe via RSS.

Copyright 2008 - 2012 | Best Blogs Asia