Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Metabox Content
- function meta_content()
- {
- $post = get_post_custom( $post->ID );
- $selected = isset( $post['meta_options'] ) ? esc_attr( $post['meta_options'][0] ) : '';
- { ?>
- <p>
- <select name="meta_options" id="meta_options">
- <option value="none" <?php selected( $selected, 'none' ); ?>>None</option>
- <?php $options =& get_children( 'post_type=attachment&post_mime_type=audio' );
- foreach ( (array) $options as $attachment_id => $attachment ) { ?>
- <option value="<?php echo $attachment_id; ?>" <?php selected( $selected, $attachment_id ); ?>><?php echo $attachment->post_title; ?></option>
- <?php } ?>
- </select>
- </p>
- <?php }}
- // Save Metabox Content
- add_action( 'save_post', 'meta_save' );
- function meta_save( $post_id )
- {
- // Check for auto-save
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- // Check for content
- if( isset( $_POST['meta_options'] ) )
- update_post_meta( $post_id, 'meta_options', esc_attr( $_POST['meta_options'] ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement