Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Last active April 12, 2017 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricBusch/005b798725ea4efd231b to your computer and use it in GitHub Desktop.
Save EricBusch/005b798725ea4efd231b to your computer and use it in GitHub Desktop.
Delete all rows in the postmeta table which have the same meta_key. [wordpress]
<?php
$meta_type = 'post'; // Type of object metadata is for (e.g., comment, post, or user).
$object_id = 0; // Set to 0 as it will be ignored.
$meta_key = 'color'; // The target "meta_key" value to delete.
$meta_value = ''; // Ignored when $delete_all is TRUE.
$delete_all = true; // True to delete matching metadata entries for all objects, ignoring the specified object_id.
delete_metadata( $meta_type, $object_id, $meta_key, $meta_value, $delete_all );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment