Metabox with value pair
-
Hi
I’m trying to set up a custom metabox with a value pair video tag name and time so that the user can link to spesific points in a video. I have the metabox set up, but I am wondering if anyone knows how I can add the paire values and how I can let the user add more than one pair.
Thank you so much in advance!
This is my code so far:
`
//Add support for custom video time-tags
add_action( ‘add_meta_boxes’, ‘videotags_meta_box_add’ );
function videotags_meta_box_add() {
add_meta_box( ‘videotags-meta-box-id’, ‘Video Tags’, ‘videotags_meta_box_cb’, ‘post’, ‘side’, ‘high’ );
}
function videotags_meta_box_cb() {
$html = ‘<label>Tag: </label><input type=”text” name=”tag” value=”‘.$value.'”/>’;
echo $html;
}
add_action( ‘save_post’, ‘videotags_meta_box_save’ );
function videotags_meta_box_save( $post_id ){
if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return;
if ( !isset( $_POST[‘pvideotags_meta_box_nonce’] ) || !wp_verify_nonce( $_POST[‘videotags_meta_box_nonce’], basename( __FILE__ ) ) ) return;
if( !current_user_can( ‘edit_post’ ) ) return;
if( isset( $_POST[‘price’] ) )
update_post_meta( $post_id, ‘price_key’, esc_attr( $_POST[‘price’], $allowed ) );
}
- The topic ‘Metabox with value pair’ is closed to new replies.