Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chiliec/85a19fdc78b78a59dab8acdc2a462496 to your computer and use it in GitHub Desktop.
Save chiliec/85a19fdc78b78a59dab8acdc2a462496 to your computer and use it in GitHub Desktop.
function change_slug_for_attachment($id) {
$post = get_post($id);
$post->post_name = uniqid('attachment');
wp_update_post($post);
}
add_action('add_attachment', 'change_slug_for_attachment');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment