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.

Programming rookie back again.

I have been studying the add_action('save_post','') but I am having difficulty getting it to work for my needs. The concept is simple - update the database information for an attachment's meta info.

Here's where I'm at. I have my add_meta_box working great with an input box that is pre-populated with the Camera information from image meta.

If I make an edit in this Camera field and update the post, no matter what variation of update_post_meta I try, it's failing. For example:

$camera = $imgmeta['image_meta']['camera'];
$update = $_POST['exif_field_camera'];
update_post_meta($post_id, $camera, $update);

I am fearing a horrible rookie mistake here, since it's not working.

The code I am using to retrieve the information and using it as part of my add_meta_box is:

$args = get_posts( array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
) );
foreach ($args as $attachment) {

$imgID = $attachment->ID;
$imgmeta = wp_get_attachment_metadata($imgID);
$camera = $imgmeta['image_meta']['camera'];
}

What would the code be to write the new Camera input box information?

share|improve this question

closed as not a real question by Rarst Oct 8 '12 at 18:55

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What are you trying to do with that foreach? You're setting those values a whole bunch of times, but not doing any output before you change them. –  m0r7if3r Mar 4 '12 at 0:22
    
The foreach sets the values for the input box that's displayed in the add_meta_box. So if the values are changed, shouldn't the $POST_() pick that up? If so, then I am doing something wrong with the update_post_meta –  Pat Mar 4 '12 at 4:51
    
So...there's more to the foreach than you posted here? –  m0r7if3r Mar 4 '12 at 11:42
    
Yes, this was a snippet. I can paste the whole thing if you feel its relevant. The foreach does not exist in my update_post_meta save_post. As I mentioned, I am able to extract data fine, I can't save it. –  Pat Mar 4 '12 at 14:13
1  
Could you please update your question with that info and clean up that comment mess (delete your own)? Thanks. –  kaiser Oct 4 '12 at 8:49

Browse other questions tagged or ask your own question.