title: Post thumbnail with checkbox in WordPress
body: <p>I try to make a checkbox in WordPress admin. I would like if the checkbox is checked, the post thumbnail is aperar. But my code is not functional. What is the problem?</p>
  
  <p>Thanks a lot.</p>
  
  <p>My checkbox code:</p>
  
  <pre><code>add_action('add_meta_boxes', 'add_ot_meta_box');
  function add_ot_meta_box() {
      add_meta_box('ot-meta-box', esc_html__('Post status', 'post_status'), 'ot_meta_box_markup', 'page', 'side', 'high', null);
      add_meta_box('ot-meta-box', esc_html__('Post status', 'post_status'), 'ot_meta_box_markup', 'post', 'side', 'high', null);
  }
  //create the boxes html markup
  function ot_meta_box_markup() {
      global $post;
      $checkbox_value = get_post_meta($post-&gt;ID, 'ot-meta-box-checkbox', true);
      wp_nonce_field(basename(__FILE__), 'ot-meta-box-nonce');
      ?&gt;
          &lt;div&gt;
              &lt;input id="ot-meta-box-checkbox" type="checkbox" name="ot-meta-box-checkbox" value="1" &lt;?php checked( $checkbox_value, 1); ?&gt;/&gt;
              &lt;label for="ot-meta-box-checkbox"&gt;&lt;?php esc_html_e('Post status') ?&gt;&lt;/label&gt;
          &lt;/div&gt;
      &lt;?php
  }
  // save checkbox meta
  function save_ot_meta_box($post_id) {
      if (!isset($_POST['ot-meta-box-nonce']) || !wp_verify_nonce($_POST['ot-meta-box-nonce'], basename(__FILE__)))
          return $post_id;
      if(!current_user_can("edit_post", $post_id))
          return $post_id;
      if(defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE)
          return $post_id;
      if( isset( $_POST['ot-meta-box-checkbox'] ) ){
          update_post_meta( $post_id, 'ot-meta-box-checkbox', true );
      } else{
          update_post_meta( $post_id, 'ot-meta-box-checkbox', false );
      }
  }
  add_action('save_post', 'save_ot_meta_box', 10, 3);
  </code></pre>
  
  <p>And my callback code in single:</p>
  
  <pre><code>&lt;?php $otoptions = get_option('ot-meta-box-checkbox');
  if ( '' !== get_the_post_thumbnail() &amp;&amp; ($otoptions['ot-meta-box-checkbox'] !== '1') &amp;&amp; is_single() ) : ?&gt;
      &lt;div class="post-thumbnail"&gt;
              &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                  &lt;?php the_post_thumbnail( 'my-featured-image' ); ?&gt;
              &lt;/a&gt;
          &lt;/div&gt;&lt;!-- .post-thumbnail --&gt;
      &lt;?php endif; ?&gt;
  </code></pre>