Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have made a plugin for wordpress which copies the image to another directory when a post has been edit. But if you only upload another featured image and don't save the post. The image has been attached to the post, but the post has not been updated. Which does not trigger my plugin function. Show which trigger (action hook) can I use to also copie the featured image?

The action which I now use for the post edit is wp_insert_post().

I forgot the reason why I use wp_insert_post(), but maybe that's why it fails ;)

share|improve this question
    
Please show your actual code. –  kaiser Dec 20 '12 at 8:04
add comment

migrated from stackoverflow.com Dec 20 '12 at 4:44

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 0 down vote accepted

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

You have two actions to hook into that process:

  • update_post_meta, before the data is written into the database
  • updated_post_meta, after the data is written into the database

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

if ( $metakey == '_thumbnail_id' ) { /*blabla*/ }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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