函数原型
delete_post_meta( int $post_id, string $meta_key, mixed $meta_value = ” ): bool
函数描述
Deletes a post meta field for the given post ID.
是否弃用
未弃用
函数参数
-
$post_id
int
Required - Post ID.
-
$meta_key
string
Required - Metadata name.
-
$meta_value
mixed
Optional - Metadata value. If provided, rows will only be removed that match the value.
Must be serializable if non-scalar.Default:
''
函数返回值
bool True on success, false on failure.
函数位置
File: wp-includes/post.php.
函数源码
function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
// Make sure meta is deleted from the post, not from a revision.
$the_post = wp_is_post_revision( $post_id );
if ( $the_post ) {
$post_id = $the_post;
}
return delete_metadata( 'post', $post_id, $meta_key, $meta_value );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

