For the second part of your question: in your args variable, you can set the selected argument to whatever is saved in your database. See the codex for more details here.
I’m currently working on the same issue, I’ll update and clarify once I figure everything out out.
EDIT : Okay! I DID IT.
Here’s my save function:
function my_custom_meta_save( $post_id ) {
// Checks save status
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ 'my_custom_nonce' ] ) && wp_verify_nonce( $_POST[ 'my_custom_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
// Exits script depending on save status
if ($is_autosave || $is_revision || !$is_valid_nonce ) {
return;
}
// Checks for input and sanitizes/saves if needed
if ( isset( $_POST[ 'meta_key' ] ) ) {
update_post_meta( $post_id, 'meta_key', $_POST[ 'meta_key' ] );
}
}
add_action( 'save_post', 'my_custom_meta_save' )
Annnnd here’s my callback function:
function my_custom_meta_callback() {
// Get the stored value from the database
global $post;
$meta = get_post_meta( $post->ID, 'sos_internal_gallery', true);
// TO DO: Exclude galleries that are already being displayed elsewhere
$args = array(
'echo' => true,
'name' => 'sos_internal_gallery',
'id' => 'sos_internal_gallery',
'show_option_none' => 'Select a slider',
'post_type' => 'sosslider',
'sort_column' => 'post_title',
'selected' => $meta
);
// Create drop down that lists all published sliders
wp_dropdown_pages( $args );
}
Hope this helps! It only took me all day to figure out.