I have a simple foreach loop and am putting together a timeline app. I'm using gravity forms to create / edit posts on the front end and am looking for a solution for a button or trigger that can delete a posts custom field (key & value) on click.

Pretty broad but along the lines of:

  • target this post in foreach
  • find meta key 'key'
  • delete meta key 'key' and its value on click

1 Answer 1


For anyone else looking for guidance on how to do this, I created another custom field called event_status and by using the save_post action in wordpress set a condition that once this changes to then the run delete_post_meta action as follows:

function event_status_is_updated($post_id){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.