get_comment_id

函式
get_comment_id ( No parameters )
返回值
  • (string) The comment ID as a numeric string.
定義位置
相關方法
get_comment_guidget_commentget_comment_dateget_comment_timeget_comment_link
引入
1.5.0
棄用
-

get_comment_id – 這個函式返回一個評論的ID。它接受一個評論物件或評論ID作為引數。

檢索當前評論的評論ID。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$comment = get_comment();
$comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0';
/**
* Filters the returned comment ID.
*
* @since 1.5.0
* @since 4.1.0 The `$comment` parameter was added.
*
* @param string $comment_ID The current comment ID as a numeric string.
* @param WP_Comment $comment The comment object.
*/
return apply_filters( 'get_comment_ID', $comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
}
function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $comment = get_comment(); $comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0'; /** * Filters the returned comment ID. * * @since 1.5.0 * @since 4.1.0 The `$comment` parameter was added. * * @param string $comment_ID The current comment ID as a numeric string. * @param WP_Comment $comment The comment object. */ return apply_filters( 'get_comment_ID', $comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase }
function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$comment    = get_comment();
	$comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0';

	/**
	 * Filters the returned comment ID.
	 *
	 * @since 1.5.0
	 * @since 4.1.0 The `$comment` parameter was added.
	 *
	 * @param string     $comment_ID The current comment ID as a numeric string.
	 * @param WP_Comment $comment    The comment object.
	 */
	return apply_filters( 'get_comment_ID', $comment_ID, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
}

常見問題

FAQs
檢視更多 >