Display stored value in Meta Box
-
How to display stored value in Meta Box ?
I added Meta Box with below code.
add_meta_box('wp_news_settings', 'News Settings', 'news_settings_html', 'news', 'normal', 'default');
My call back function is like below
public function news_settings_html($post) { $wpwi_stored_meta = get_post_meta($post->ID); $fields = [ 'location' => '<input type="text" value="'. (!empty($wpwi_stored_meta) && $wpwi_stored_meta['location']) ? $wpwi_stored_meta['location'][0] : ''.'" name="location" />', ]; wp_nonce_field(basename(__FILE__), 'wpwi_nonce'); ?> <table class="form-table"> <?php foreach($fields as $key=> $field) { ?> <tr valign="top"> <th scope="row"> <label for="location"> <?= _e(ucfirst($key), 'textdomain');?> </label> </th> <td> <?= $field; ?> </td> </tr> <?php } ?> </table> <?php }
But I am not getting Stored Value in Meta Box .
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display stored value in Meta Box’ is closed to new replies.