get_comment_meta()获取一个评论的meta自定义附加信息

目录

描述

get_comment_meta() allows you to pull any meta values stored against comments, which have been set using add_comment_meta(). Similar method to get_post_meta().

Useful within the comments.php template when displaying comments against a post.

get_comment_meta() 描述

用法

<?php $meta_values get_comment_meta$comment_id$key$single ); ?> 

get_comment_meta() 用法

参数

$comment_id

(integer) (必填) The ID of the comment from which you want the data. Use $comment->comment_ID to get a comment's ID.

默认值: None

$key

(string) (可选) A string containing the name of the meta value you want. By default, returns data for all keys.

默认值: None

$single

(boolean) (可选) If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields. This is not intuitive. For example, if you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string.

默认值: false

get_comment_meta() 参数

注意

历史

添加于 版本: 2.9.0

get_comment_meta() 历史

源文件

get_comment_meta() 函数的代码位于 wp-includes/comment.php

get_comment_meta() 源文件

相关