Skip to content

Instantly share code, notes, and snippets.

@traversal
Last active August 29, 2015 14:12
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 traversal/ed1eb9a033a51e44b35d to your computer and use it in GitHub Desktop.
Save traversal/ed1eb9a033a51e44b35d to your computer and use it in GitHub Desktop.
Edit attachment
<?php
function my_update_media($object_id, $object_type) {
global $wf;
if ($object_type == "post") {
$post = $wf->post($object_id);
if ($post->is_an("attachment")) {
update_post_meta($object_id, "details.field", "update!!" . $object_id . time());
}
}
}
add_action("mp_after_save_meta", "my_update_media", 100, 2);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment