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've got a custom meta box for a custom post type which will be the only metabox I plan to show in the main column (except the native title box). I want to move the native Expert box/field inside my Custom Meta Box.

I'm able to create a field called Excerpt in my Meta Box, however I only know how to save this to the Custom Fields, not the original location that the native Except saves to.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Just name the field 'excerpt'.

E.g.:

<textarea name="excerpt" id="excerpt"><?php echo esc_html( '$post->post_excerpt' ); ?></textarea> <!-- if it is a textarea field -->

or

<input name="excerpt" id="excerpt" value="<?php echo esc_attr( '$post->post_excerpt' ); ?>" /> <!-- if it is a text field -->
share|improve this answer
    
Where can I find the documentation to do this with other metaboxes? I guess I really only need to know the IDs of the other wordpress native metaboxes. –  matt Dec 6 '10 at 17:21
    
Nevermind, that was a silly question. I just looked at the code in firebug and it was right there. –  matt Dec 6 '10 at 17:25

This would be a function to update the post_excerpt with a field with the name 'my_custom_field'.

function my_custom_save_function($post_id){
    update_post(array('ID' => $post_id, 'post_excerpt' => $_POST['my_custom_field']));
}
add_action('save_post', 'my_custom_save_function');
share|improve this answer
    
I figured it would be done with a hook but I'm wondering why you prefer this approach to the one sorich suggested? His seems a little lighter. –  matt Dec 6 '10 at 16:11
    
I prefer this way as it seens to me a much cleaner to me and its easier to extend. Normally you gonna add much more fields then just one and then you have to use this hook anyway. –  Horttcore Dec 7 '10 at 8:13

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.