Title: Save Custom Post Value
Last modified: June 30, 2022

---

# Save Custom Post Value

 *  [mabufoysal](https://wordpress.org/support/users/mabufoysal/)
 * (@mabufoysal)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/save-custom-post-value/)
 * I am learning WordPress Plugin Development. I have custom post type `News`. I
   am taking input using meta-boxes for this custom post.
 * I added metabox using below code.
 *     ```
       add_meta_box('news_settings', 'News Settings', [ $this, 'news_settings_html' ], 'News', 'normal', 'default');
       ```
   
 * My meta box code is like below.
 *     ```
       public function news_settings_html()
       {
           <?php
               <label for="location">
                   <?php _e('Location', 'textdomain');?>
               </label>            
               <input type="text" name="location"/>
           ?>
       }
       ```
   
 * How can I save this meta-boxes values ?
    -  This topic was modified 3 years, 11 months ago by [mabufoysal](https://wordpress.org/support/users/mabufoysal/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Hardik Thakkar](https://wordpress.org/support/users/thakkarhardik/)
 * (@thakkarhardik)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/save-custom-post-value/#post-15785116)
 * You can save the meta box values using the `save_post` action hook. Please refer
   these documentations:
 * [https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/#saving-values](https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/#saving-values)
   
   [https://developer.wordpress.org/reference/hooks/save_post/](https://developer.wordpress.org/reference/hooks/save_post/)
   [https://developer.wordpress.org/reference/hooks/save_post_post-post_type/](https://developer.wordpress.org/reference/hooks/save_post_post-post_type/)
 * Thanks.
 *  [Ambikesh Gautam](https://wordpress.org/support/users/ambikesh021/)
 * (@ambikesh021)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/save-custom-post-value/#post-15792175)
 * add_action( ‘save_post’, ‘save_news_settings’ );
    function save_news_settings(
   $post_id ){ // You can get saved values in this way $saved_value = get_post_meta(
   $post_id, ‘news_settings’, true ); $value_from_meta_box = $_POST[‘news_settings’];
   update_post_meta($post_id, ‘news_settings’, $value_from_meta_box ); }
 * I hope this will help you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Save Custom Post Value’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [Ambikesh Gautam](https://wordpress.org/support/users/ambikesh021/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/save-custom-post-value/#post-15792175)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
