I am working with wordpress, I am getting following data in loop,"Id" is our "postid",And i want to delete only single attribute/key(profile_image) using that "postid",which i am getting in loop
Array
(
[id] => 46456
[status] => approved
[profile_image] => isProfile
)
Array
(
[id] => 46457
[status] => approved
[profile_image] => isProfile
)
Array
(
[id] => 46458
[status] => approved
[profile_image] => isProfile
)
Here is my code,How can i do this ?
foreach($datas as $data)
{
echo "<pre>";print_r($data);
delete_metadata( 'post', null, 'profile_image', '', true );
}
Where i am wrong ?
2
Answers
You can delete post meta using delete_post_meta function.
WordPress function delete_post_meta