skip to Main Content

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


  1. You can delete post meta using delete_post_meta function.

    forech($posts as $post){
        delete_post_meta($post->ID, 'profile_image');
    }
    
    Login or Signup to reply.
  2. WordPress function delete_post_meta

    <?php delete_post_meta(76, 'my_key', 'Steve'); ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search