Which action hook can I use when a featured image has been selected

The set_post_thumbnail function uses the metadata functions to set the featured image.

You have two actions to hook into that process:

EDIT: The action hooks are now defined different

Thanks @dalbaeb!

  • update_postmeta, before the data is written into the database. Previously update_post_meta
  • updated_postmeta, after the data is written into the database. Previously updated_post_meta

SECOND EDIT: No need to panic

updated_{$meta_type}_meta and update_{$meta_type}_meta still work.

You will have to make a conditional, and be good to go:

if ( $metakey == '_thumbnail_id' ) { /*blabla*/ }

Leave a Comment