title: WordPress custom meta box wont save
body: <p>I have the following code which adds a custom meta box to wordpress pages but for some reason it wont save the selected option. Any ideas whats wrong ?</p>
  
  <p>Thanks.</p>
  
  <pre><code> // Add Header Select Option MetaBox
  function alfie_header_select_meta() {
  add_meta_box( 'alfie_header_select_meta', __( 'Header Style', 'alfie' ), 'alfie_header_select_meta_callback', 'page', 'side' );
  }
  add_action( 'add_meta_boxes', 'alfie_header_select_meta' );
  
  function alfie_header_select_meta_callback( $post ) {
  $values = get_post_custom( $post-&gt;ID );
  $selected = isset( $values['alfie_selected_header'] ) ? esc_attr( $values['alfie_selected_header'][0] ) : ”;
  wp_nonce_field( 'alfie_header_select_meta_nonce', 'alfie_header_select_meta_nonce' );
  ?&gt;
    &lt;p&gt;
        &lt;select name="alfie_selected_header" id="alfie_selected_header"&gt;
            &lt;option value="alfie-header-default" &lt;?php selected( $selected, 'default' ); ?&gt;&gt;Default&lt;/option&gt;
            &lt;option value="alfie-header-style-minimal" &lt;?php selected( $selected, 'minimal' ); ?&gt;&gt;Minimal&lt;/option&gt;
            &lt;option value="alfie-header-test" &lt;?php selected( $selected, 'test' ); ?&gt;&gt;Just a test option&lt;/option&gt;
        &lt;/select&gt;
    &lt;/p&gt;
  &lt;?php
  }
  
  function alfie_meta_save( $post_id ) {
  $is_autosave = wp_is_post_autosave( $post_id );
  $is_revision = wp_is_post_revision( $post_id );
  $is_valid_nonce = ( isset( $_POST[ 'alfie_header_select_meta_nonce' ] ) &amp;&amp; wp_verify_nonce( $_POST[ 'alfie_header_select_meta_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
  
  if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
      return;
  }
  
  if( isset( $_POST[ 'alfie_selected_header' ] ) ) {
      update_post_meta( $post_id, 'alfie_selected_header', sanitize_text_field( $_POST[ 'alfie_selected_header' ] ) );
  }
  }
  add_action( 'save_post', 'alfie_meta_save' );
  </code></pre>