delete_comment_meta()

删除一个评论的meta自定义附加信息

描述

从注释中删除元数据匹配条件。您可以根据键或键和值进行匹配。基于键和值进行删除将防止删除具有相同键的重复元数据。如果需要,它还允许删除所有元数据匹配键。

delete_comment_meta() 允许您删除针对注释存储的任何元值,这些值是使用 add_comment_meta() 设置的。与 delete_post_meta() 类似的方法。

用法

<?php delete_comment_meta( $comment_id, $meta_key, $meta_value ); ?>

参数

$comment_id

(integer) (必填) Comment ID

默认值: None

$meta_key

(string) (必填) Metadata key

默认值: None

$meta_value

(mixed) (可选) Metadata value

默认值: Empty string

返回值

(boolean

假表示失败。成功是真的。

示例

/* ———————————-
* wordpress函数 星空站长网收集
* ———————————- */
<?php
// Delete all metadata with the key ‘my_meta_key’ for comment ID 5.

delete_comment_meta( 5, ‘my_meta_key’ );

// Delete metadata for ‘my_meta_key’ only where the meta_value is ‘foo’.

delete_comment_meta( 5, ‘my_meta_key’, ‘foo’ );

?>

注意

使用到 delete_metadata().

历史

添加于 版本: 2.9.0

源文件

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

/* ———————————-
* wordpress函数 XingkongWeb.com收集
* ———————————- */
/**
* Remove metadata matching criteria from a comment.
*
* You can match based on the key, or key and value. Removing based on key and
* value, will keep from removing duplicate metadata with the same key. It also
* allows removing all metadata matching key, if needed.
*
* @since 2.9.0
* @link https://codex.wordpress.org/Function_Reference/delete_comment_meta
*
* @param int $comment_id comment ID
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value.
* @return bool True on success, false on failure.
*/

function delete_comment_meta($comment_id, $meta_key, $meta_value = ”) {

return delete_metadata(‘comment’, $comment_id, $meta_key, $meta_value);

}
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索