get_comment_author

Definition:
function get_comment_author( $comment_ID = 0 ) {}

Retrieve the author of the current comment.
If the comment has an empty comment_author field, then ‘Anonymous’ person is assumed.

Parameters

  • int $comment_ID: The ID of the comment for which to retrieve the author. Optional.

Return values

returns:The comment author

Defined filters

  • get_comment_author
    apply_filters('get_comment_author', $author)

Source code

function get_comment_author( $comment_ID = 0 ) {

	$comment = get_comment( $comment_ID );

	if ( empty($comment->comment_author) ) {

		if (!empty($comment->user_id)){

			$user=get_userdata($comment->user_id);

			$author=$user->user_login;

		} else {

			$author = __('Anonymous');

		}

	} else {

		$author = $comment->comment_author;

	}

	return apply_filters('get_comment_author', $author);

}

1290

get_comments_popup_template

Definition:
function get_comments_popup_template() {}

Retrieve path of comment popup template in current or parent template.
Checks for comment popup template in current template, if it exists or in the parent template.

Source code

function get_comments_popup_template() {

	$template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) );



	// Backward compat code will be removed in a future release

	if ('' == $template)

		$template = ABSPATH . WPINC . '/theme-compat/comments-popup.php';



	return $template;

}

1288

get_comments_pagenum_link

Definition:
function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {}

Retrieve comments page number link.

Parameters

  • int $pagenum: Optional. Page number.
  • $max_page

Defined filters

  • get_comments_pagenum_link
    apply_filters('get_comments_pagenum_link', $result)

Source code

function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {

	global $post, $wp_rewrite;



	$pagenum = (int) $pagenum;



	$result = get_permalink( $post->ID );



	if ( 'newest' == get_option('default_comments_page') ) {

		if ( $pagenum != $max_page ) {

			if ( $wp_rewrite->using_permalinks() )

				$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');

			else

				$result = add_query_arg( 'cpage', $pagenum, $result );

		}

	} elseif ( $pagenum > 1 ) {

		if ( $wp_rewrite->using_permalinks() )

			$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');

		else

			$result = add_query_arg( 'cpage', $pagenum, $result );

	}



	$result .= '#comments';



	$result = apply_filters('get_comments_pagenum_link', $result);



	return $result;

}

1286

get_comments_number

Definition:
function get_comments_number( $post_id = 0 ) {}

Retrieve the amount of comments a post has.

Parameters

  • int $post_id: The Post ID

Return values

returns:The number of comments a post has

Defined filters

  • get_comments_number
    apply_filters('get_comments_number', $count, $post_id)

Source code

function get_comments_number( $post_id = 0 ) {

	$post_id = absint( $post_id );



	if ( !$post_id )

		$post_id = get_the_ID();



	$post = get_post($post_id);

	if ( ! isset($post->comment_count) )

		$count = 0;

	else

		$count = $post->comment_count;



	return apply_filters('get_comments_number', $count, $post_id);

}

1284

get_comments_link

Definition:
function get_comments_link($post_id = 0) {}

Retrieves the link to the current post comments.

Parameters

  • int $post_id: Optional post id

Return values

returns:The link to the comments

Source code

function get_comments_link($post_id = 0) {

	return get_permalink($post_id) . '#comments';

}

1282