title: How to display custom meta box value in single post in wordpress?
body: <p><a href="https://i.stack.imgur.com/e0lmW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e0lmW.jpg" alt="enter image description here"></a><a href="https://i.stack.imgur.com/Vf3F3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vf3F3.jpg" alt="enter image description here"></a>I am trying to make custom meta box and display it's value in single post,but code doesn't display value in single post.The value is stored in post at admin side,i want to display that value as front end side as well.Right now i am using twenty seventeen theme.i am using this code for custom meta box in function.php file:</p>
  
  <pre><code>add_action( 'add_meta_boxes', 'm_param_meta_box_add' );
  function m_param_meta_box_add() {
      add_meta_box( 'm_param_post', 'Box Title', 'm_param_post_meta_box_cb', 'post', 'normal', 'high' );
  }
  
  function m_param_post_meta_box_cb( $post )
  {
      $values = get_post_custom( $post-&gt;ID );
      if ( isset( $values['m_meta_description'] ) ) {
          $m_meta_description_text = esc_attr( $values['m_meta_description'][0] );
      }
      wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
  
  ?&gt;
  &lt;table class="form-table"&gt;
  &lt;tr valign="top"&gt;
  &lt;th scope="row"&gt;&lt;label for="m_meta_description"&gt;Post Description&lt;/label&gt;&lt;/th&gt;
  &lt;td&gt;&lt;textarea rows="3" cols="50" name="m_meta_description"&gt;&lt;?php echo $m_meta_description_text; ?&gt;&lt;/textarea&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;?php
  } // close m_param_post_meta_box_cb function
  
  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;
  
      // Make sure your data is set before trying to save it
      if( isset( $_POST['m_meta_description'] ) ) {
          update_post_meta( $post_id, 'm_meta_description', wp_kses( $_POST['m_meta_description']) );
      }    
  }
  
  add_action('wp_head', 'add_to_wp_head');
  function add_to_wp_head( )
  {
      if (is_single())
      {
          global $post;
          $m_meta_description = get_post_meta($post-&gt;ID, 'm_meta_description', true);
          echo '&lt;meta name="description" content="' . $m_meta_description . '"/&gt;';
      }
  }
  </code></pre>
  
  <p>The code that i am trying in single.php is look like:</p>
  
  <pre><code>               &lt;?php
                  add_action('wp_head', 'add_to_wp_head');
                  function add_to_wp_head( )
                  {
                      if (is_single())
                      {
                          global $post;
                          $m_meta_description = get_post_meta($post-&gt;ID, 'm_meta_description', true);
                          echo '&lt;meta name="description" content="' . $m_meta_description . '"/&gt;';
                      }
                  }
                  ?&gt;
  </code></pre>