Firstly,
you have to pass get_post_meta() field name in your input type name which you have to store user data value and if it’s not created then it will create in save_your_fields_metabox() function.
public function news_settings_html($post){
global $post;
$meta = get_post_meta($post->ID, 'your_store_field_name', true);
<input type="hidden" name="your_meta_box_nonce" value="<?php echo wp_create_nonce(basename(__FILE__)); ?>">
<input type="text" value="<?php
if (is_array($meta) && isset($meta['text-address'])) {
echo $meta['text-address'];
}
?>" name="your_store_field_name[text-address]" />
}
you have to store your textbox value in database,then you can get them on front page.
function save_your_fields_metabox($post_id) {
// verify nonce
if (isset($_POST['your_meta_box_nonce']) && !wp_verify_nonce($_POST['your_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if (isset($_POST['post_type'])) {
if ('careers' === $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
}
}
// if field is not created early then it will create here!
$old = get_post_meta($post_id, 'your_store_field_name', true);
if (isset($_POST['your_store_field_name'])) {
$new = $_POST['your_store_field_name'];
if ($new && $new !== $old) {
update_post_meta($post_id, 'your_store_field_name', $new);
} elseif ('' === $new && $old) {
delete_post_meta($post_id, 'your_store_field_name', $old);
}
}
}
add_action('save_post', 'save_your_fields_metabox');
and on front page, suppose it’s page.php , just you have to get meta field name and get with it’s input text name.
$meta = get_post_meta($post->ID, 'your_store_field_name', true);
<h1>Text Input</h1>
<?php echo $meta['text-address']; ?>
Please try to get data from post meta, if it’s really stored or not.
you can refer this, in detail Metabox
<?php
$args = array('post_type' => 'news');
$the_query = new WP_Query($args);
while ( $the_query->have_posts() ) : $the_query->next_post();
$id= $the_query->post->ID;
$location = get_post_meta($id, 'your_store_field_name', true);
echo $location;
endwhile;
?>