I'm simply trying to use a plugin hook within my own function to add a custom field to each post when it's published. But I can't quite figure out how to make the function work. Here's what I have so far:
function custom_medium($postID) {
global $post;
$postID = $post->ID;
$custom = get_the_image( array( 'default_size' => 'large', 'link_to_post' => false, 'image_scan' => true ) );
update_post_meta($postID, 'medium', ''.$custom.'');
}
add_action('publish_post', 'custom_medium');
I'm using the Get The Image plugin to grab the first attached image for each post, and need to register what it finds as a custom field called "medium".
As always, any help is greatly appreciated. Thanks in advance.