wordpress - My Custom Meta Box Won't Save -


i have created custom post type , added meta boxes. able display custom post type on front end built in elements such post title , featured image. when saving information in meta box clears fields when save post. here code:

add_action( 'add_meta_boxes', 'fellowship_church_information' ); function fellowship_church_information() { add_meta_box(      'fellowship_church_information',                    // unique id     __( 'church information', 'myplugin_textdomain' ),  // title     'fellowship_church_information_content',            // callback function     'fellowship',                                       // admin page (or post type)     'normal',                                           // context     'default'                                           // priority ); }  function fellowship_church_information_content( $post ) { echo '<div class="fellowship-church-information-form">      <label for="church_name">church name: </label> <input type="text" id="church_name" name="church_name" placeholder="" /> <br />      <label for="church_address">church address: </label> <input type="text" id="church_address" name="church_address" placeholder="" /> <br />      <label for="church_city">church city: </label> <input type="text" id="church_city" name="church_city" placeholder="" />      <label for="church_state">church state: </label>      <select id="church_state" name="church_state" placeholder="">         <option value="al">alabama</option>         <option value="wy">wyoming</option>     </select>      <label for="church_zip">church zip: </label> <input type="text" id="church_zip" name="church_zip" placeholder="" />     <input type="hidden" name="fellowship_noncename" id="fellowship_noncename" value="' . wp_create_nonce( 'fellowship-nonce' ) . '" />     </div>       '; }   //  saving information database  add_action( 'save_post', 'fellowship_church_information_save', 10, 6 ); function fellowship_church_information_save( $post_id ) {    if ( defined( 'doing_autosave' ) && doing_autosave )    return;    if ( 'fellowship' == $_post['post_type'] ) {     if ( !current_user_can( 'edit_page', $post_id ) )     return;   } else {     if ( !current_user_can( 'edit_post', $post_id ) )     return;   }   if (isset($_post['fellowship_noncename'])){     if ( !wp_verify_nonce( $_post['fellowship_noncename'], 'fellowship-nonce' ) )         return;   }else{       return;   }   $fellowship_church_information = $_post['fellowship_church_information'];   update_post_meta( $post_id, 'fellowship_church_information', $_post['fellowship_church_information'] ); }     //  add shortcode -- [fellowships] function fellowships_func( $atts ){  //  displaying information $queryfellowship = array(       'post_type' => 'fellowship',     );  $fellowships = new wp_query( $queryfellowship );     if( $fellowships->have_posts() ) {       while( $fellowships->have_posts() ) {         $fellowships->the_post();         echo '<h1>' . the_title() . '</h1>';         echo '<div class="fellowships-content">';         if ( has_post_thumbnail() ) {             the_post_thumbnail();         }         the_content();         get_metadata();         $meta = get_post_meta( get_the_id() );         echo $meta;         echo '</div>';       }     }     else {       echo '<h2 class="no-fellowships">there no upcoming alumni &amp; friends fellowships.</h2>';     }  } add_shortcode( 'fellowships', 'fellowships_func' ); 

again, able display title , featured image not custom meta.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -