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.

My meta box won't save data. It's a select form field and when I select and update the post, there's nothing selected on refresh.

So here it is on PasteBin. http://pastebin.com/tfrgasQC

Can anyone tell why my code won't get wordpress to save the post with the data?

Thanks

share|improve this question

closed as too localized by Rarst Oct 21 '11 at 11:50

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

If that is all of your code, you're missing a save_post action to save the data. Refer to the code sample provided on add_meta_box.

add_action( 'save_post', 'save_my_meta_box_data' );

function save_my_meta_box_data( $post_id ){
    // make sure it's not an autosave
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
        return;

    // verify your nonce
    if ( !wp_verify_nonce( $_POST['my_noncename'], 'my-nonce' ) )
        return;

    // check post type, permissions
    // validate your $_POST data
    // update_post_meta();
}
share|improve this answer
    
Thank you for your answer! What is a nonce though? I looked it up and it's security related. I don't have any nonces that I know of. –  Ian Mason Oct 21 '11 at 3:27
    
Oh I see, your code wasn't meant to be pasted into my file. LOL sorry... I don't know anything about coding :/ –  Ian Mason Oct 21 '11 at 3:53
    
Can you show me how to write the save function for my specific code? I'm sorry for asking but I've been working on this all day, trying to write save functions different ways since I don't know php, and it just fails every time. –  Ian Mason Oct 21 '11 at 4:43
    
ok I figured it all out using something else... don't know how to show it here though... wish I could delete this question. waste of space, sorry guys –  Ian Mason Oct 21 '11 at 6:16

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