comment_author( int|WP_Comment $comment_ID )
Displays the author of the current comment.
描述
参数
- $comment_ID
-
(int|WP_Comment)
(Optional)
WP_Comment or the ID of the comment for which to print the author. Default current comment.
源代码
File: wp-includes/comment-template.php
function comment_author( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
$author = get_comment_author( $comment );
/**
* Filters the comment author's name for display.
*
* @since 1.2.0
* @since 4.1.0 The `$comment_ID` parameter was added.
*
* @param string $author The comment author's username.
* @param int $comment_ID The comment ID.
*/
echo apply_filters( 'comment_author', $author, $comment->comment_ID );
}
更新日志
Version | 描述 |
---|---|
4.4.0 | Added the ability for $comment_ID to also accept a WP_Comment object. |
0.71 | Introduced. |
相关函数
Uses
-
wp-includes/plugin.php:
apply_filters() -
wp-includes/comment-template.php:
get_comment_author() -
wp-includes/comment-template.php:
comment_author -
wp-includes/comment.php:
get_comment()
Used By
-
wp-admin/includes/class-wp-comments-list-table.php:
WP_Comments_List_Table::column_author()
User Contributed Notes
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Basic Example
<div>Comment by <?php comment_author(); ?>:</div>
你可能对这些文章感兴趣:
- wordpress函数export_wp()用法示例
- wordpress函数extract_from_markers()用法示例
- wordpress函数export_add_js()用法示例
- wordpress函数export_date_options()用法示例
- wordpress函数esc_textarea()用法示例
- wordpress函数esc_url()用法示例
- wordpress函数esc_url_raw()用法示例
- wordpress函数esc_js()用法示例
- wordpress函数esc_sql()用法示例
- wordpress函数esc_html__()用法示例
- wordpress函数esc_html_x()用法示例
- wordpress函数esc_html()用法示例
- wordpress函数esc_html_e()用法示例
- wordpress函数esc_attr_x()用法示例
如有疑问,请前往问答中心反馈!
反馈