Here’s an updated version of save_TFP_meta()
, which has modified saving logic. It fixes the issue where the meta data was not being saved after being emptied.
function save_TFP_meta( $post_id, $post ) {
if ( ! wp_verify_nonce( $_POST['TFP_meta_box_nonce'], plugin_basename( __FILE__ ) ) )
return $post_id;
if ( ! current_user_can( 'edit_post', $post_id ) )
return $post_id;
$TFP_meta_value = get_post_meta( $post_id, 'TFP', true );
$new_TFP_meta_value = stripslashes( $_POST['TFP'] );
if ( false !== $TFP_meta_value && '' == $new_TFP_meta_value ) {
delete_post_meta( $post_id, 'TFP', $TFP_meta_value );
} else {
update_post_meta( $post_id, 'TFP', $new_TFP_meta_value );
}
}
Related Posts:
- Adding another state (spam, reject, approve) to wordpress comments?
- Problem in custom meta boxes
- Multiplile values checkbox or select in custom meta box
- Better Method for Multiple Meta Boxes
- I need a “Choose from existing content” popin
- How can I hide custom field from users used for caching response from external api?
- Let’s Create Custom Field Template Documentation
- Custom meta boxes not saving
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- Make separate text boxes for separate WordPress Custom Fields
- Save input form on custom field
- When post is updated, custom metadata in text area field is overwritten
- ‘Preview Changes’ for custom meta boxes?
- Using TinyMce with textareas in meta boxes on custom post types
- add meta box – custom field : which to choose?
- Add metabox to document tab in gutenberg
- Add custom objects/entities to WordPress
- How can I avoid re-inventing the Custom Fields wheel in my Plugin’s Metabox?
- Add custom option to Standard Page Attributes Meta Box
- Only show metabox when date-value in other metabox is over?
- Making a configurable field translatable
- Is there a way to do multiple ordering on a multiple meta_query?
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Create meta boxes that don’t show in custom fields
- Custom Fields Bulk Edit
- Custom Page Template [closed]
- wp_editor in add_meta_boxes does not show gallery
- Problem with adding exta field in metabox in custom post type
- Adding a custom field or metabox to the post-thumbnail widget?
- How do I add custom_meta_box_id’s value?
- how to save multiple custom fields for a post in one go?
- Best way to add custom / magic / flutter fields into RSS feed
- My metabox class
- Loading scripts to the Post Edit page only
- Woocommerce with metabox plugin
- How do you create dynamic customised sections in WordPress?
- How to Display Custom Meta Box only on Specific Page IDs
- Dynamically add / duplicate custom meta in custom post types
- How to check for specific meta box value on front end and output accordingly
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- Tweak Meta for Post to work it for Pages also
- Create Multiple File Upload Metabox in WordPress
- Users Select inside custom metabox
- Custom Metabox Not Saving
- Should custom meta boxes be able to output shortcodes the same as WordPress’ native post editor?
- How to make condition, based on custom fields value?
- How to select posts from multiple categories and metavalues?
- Custom Meta Box (SELECT) Not Saving
- Get updated meta value after post update or published (custom post type) using hook
- Why is my Custom Meta Box Field Inputs NOT saving?
- custom-meta-box checkboxes from loop won’t save
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Outputing a metabox textarea and avoid line breaks inside li tags
- shortcode in a custom metabox
- Problem with saving large amount of data in postmeta/usermeta
- How to use media upload on metabox post page without breaking TinyMCE?
- How to query an out put value?
- Displaying Meta-Box Data Properly
- frontend submit post jQuery clone row won’t save
- Get text from user and display it on page
- Custom Fields Question
- If metabox has content display content
- HM CMB: Role Select
- Get meta field value of all catgories
- How to get all custom fields with some prefix in key?
- WP-eComerce Advance Meta Tag data in descending order [closed]
- How to store meta field values
- How to Convert Custom Fields from Text to Array?
- Adding re-type email and check it if the email match
- Approach to creating a site with this structure
- show a specific metabox dependent on the page template
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Set class if a meta value is set within post archive
- Using Customizer API vs Custom Meta Box for custom content
- How can I ‘check’ the “custom fields” box from the Screen Options?
- Allow HTML in Custom Metabox area
- Metabox/Custom fields are not saving input data
- Custom field metabox not showing in back-end
- WordPress admin area: select box with 12.000+ options
- Remove Custom metabox from particular page template is used
- How to display selected option from dropdown list in a metabox
- Save, update, get and sanitize post meta as HTML not plain
- Update custom table on metabox POST
- Metabox value for post loop?
- how to modify a field’s size in a metabox : ROWS height, and scroll control?
- Append custom field items to content from plugin
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- Extend WP_Customize_Control with Multiple Field Control
- custom field functionality
- How to add an option to admin to add image that could be used as header?
- Show or hide lang=”ur” in main element
- How can I create more “create attachment” custom field – any idea?
- Custom Metaboxes, multiple post selection
- added a meta box to post however when saving menu while debug on throws a warning
- Use Metabox to enter Post Title
- Include custom fields into the content of a regular page
- How to get the value of particular get $meta value in wordpress
- Display custom field value into content with hyperlink
- Add image custom attribute [closed]
- Add fields to edit in custom widget