title: How do I display Youtube/Vimeo video ID on custom post type when user enters it in custom meta box?
body: <p>I have created a 2x shortcodes that displays a youtube video and vimeo video when the user enters the videos id in it, for emample: [youtube id=""] [vimeo id=""].</p>
  
  <p>Instead of entering this in my post I am trying to create a custom meta box that the user can enter the id in and then this is displayed.</p>
  
  <p>So far I have been able to create a plugin to display the meta box but I'm not sure how to get it to save the youtube/vimeo ID and display the video.</p>
  
  <p>Will I need 2x different meta boxes? One that the user can enter the youtube video ID in and the other where the vimeo ID can be entered and then this is displayed on the front end?</p>
  
  <p>The code I have for the meta box is:</p>
  
  <pre><code>add_action( 'add_meta_boxes', 'cd_meta_box_add' );
  function cd_meta_box_add()
  {
      add_meta_box( 'my-meta-box-id', 'Enter Video ID', 'cd_meta_box_cb', 'videos', 'normal', 'high' );
  }
  
  function cd_meta_box_cb( $post )
  {
      $values = get_post_custom( $post-&gt;ID );
      $text = isset( $values['my_meta_box_text'] ) ? esc_attr( $values['my_meta_box_text'][0] ) : '';
  
      wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
      ?&gt;
      &lt;p&gt;
          &lt;label for="my_meta_box_text"&gt;Youtube/Vimeo ID:&lt;/label&gt;
          &lt;input type="text" name="my_meta_box_text" id="my_meta_box_text" value="&lt;?php echo $text; ?&gt;" /&gt;
      &lt;/p&gt;
  
  
      &lt;?php   
  }
  
  
  add_action( 'save_post', 'cd_meta_box_save' );
  function cd_meta_box_save( $post_id )
  {
      // Bail if we're doing an auto save
      if( defined( 'DOING_AUTOSAVE' ) &amp;&amp; DOING_AUTOSAVE ) return;
  
      // if our nonce isn't there, or we can't verify it, bail
      if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
  
      // if our current user can't edit this post, bail
      if( !current_user_can( 'edit_post' ) ) return;
  
      // now we can actually save the data
      $allowed = array( 
          'a' =&gt; array( // on allow a tags
              'href' =&gt; array() // and those anchords can only have href attribute
          )
      );
  
      // Probably a good idea to make sure your data is set
      if( isset( $_POST['my_meta_box_text'] ) )
          update_post_meta( $post_id, 'my_meta_box_text', wp_kses( $_POST['my_meta_box_text'], $allowed ) );
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>I also think I need to run a loop on my single-video.php template so that wordpress knows to display the ID from the custom meta box. For the loop this is all I have so far:</p>
  
  <pre><code>$args = array( 'post_type' =&gt; 'videos', 'posts_per_page' =&gt; 10, 'orderby' =&gt; 'date', 'order' =&gt; 'ASC' );
                      $loop = new WP_Query( $args );
                      while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); 
  </code></pre>
  
  <p>That isnt finished though so I would really appreciate any help.</p>