There were three issues:
The first wasn’t visible in the code presented. a wp_register_styles call was put into the constructor, which caused errors and somehow prevented saving post metadata.
Second, the date field was a HTML5 date field, which conflisted with jQuery’s datepicker. Changing it to a text field fixed that.
Third, the final if statement in the save_meta function would evaluate true whether the metakey existed or not. If it did exist, it wouldn’t get updated since that statement had the add_post_meta function. The second conditional statement ($new_meta_value && $new_meta_value != $meta_value) would be true in both cases and used the update_post_meta function, which will also create a new metakey if it doesn’t already exist.
Related Posts:
- Passing error/warning messages from a meta box to “admin_notices”
- Metabox with checkbox is not updating
- Why can’t I hook into save_posts after admin_init?
- Save checkboxes of a metabox with a foreach loop (invalid argument)
- prevent post submission
- Metabox of one post influence setting on other
- unable to save post meta on single field with multiple selects
- Undefined ‘post_type’ error on Add new page
- Metabox saves on Update or Publish, but not on Saving Draft
- save_post action to include wp_insert_post_data filter, gathering meta field info & prevent infinite loop
- Meta box html is not updating after saving
- Getting gutenberg (WordPress 5) to save TInymce data?
- Stop saving process when metabox is invalid [duplicate]
- Why does not my metabox save?
- Migrating from metaboxes to wp_editor()
- Save meta data with post, Without using any plugin [closed]
- Editor meta box Showing but not saving
- save radio button selection in post-meta on submit
- Post and Pages section inside WordPress admin are completely blank
- Saving multiple fields (dropdown and text) in custom metabox
- Meta Box – Javascript Datatable
- A correct hook for saving meta boxes data
- Add a Meta Box for uploading a SECOND Featured Image?
- Remove the Yoast SEO Post Metabox [closed]
- Sample code for validating custom metabox?
- How to add a class to meta box
- Add Meta box Befoure Post Title
- Editing Screen: Make Update or Publish Button Follow The Page
- Meta Boxes in Front End Post Submission Form
- Custom meta box shown when template is chosen [duplicate]
- Modifying the main editor priority
- How to make a meta box field a requirement
- Adding uploaded images to editor from metabox instead of default popup uploader
- Choosing a default page tempate (Classic => Gutenberg)
- How to remove the RichText Meta Box
- Replace the Post Excerpt Meta Box with a Field in My Custom Meta Box
- Add character count to custom metabox
- Update caption for metabox gallery images
- How to show post format gallery metabox image caption in the post front end
- datetime_timestamp shows numbers only? need in date and time
- Custom Metabox with Ajax in Edit Post – Stuck
- Post.php – Conditional statements for new post and edit post
- How to generate a featured image from a video embeded in a metabox
- Meta box io oembed returns list not array
- How to verify meta box is registered in Unit Testing?
- Add a custom field to top attribute in WooCommerce
- wp_editor in metabox not working
- Select box saves but doesn’t update value in admin
- Is it possible to create a post using a metabox?
- retrieve meta key when checkbox is used
- Add Meta Box not showing on New Post – Custom meta box not showing
- Customize WordPress Media Upload and New Media Manager Menu in add post Metabox
- How to display a custom post type’s media library inline on meta box
- Modules with meta box implementations
- Remove meta box for specific page
- How To Add Custom Meta PDF Upload Box to WooCommerce Products (and post link on frontend)
- Using WYSIWYG In custom meta boxes
- Visual/Text tabs in wp editor Not Showing
- Change the context of excerpt metabox for the ‘New Post’ page
- How to have meta boxes save via REST in Gutenberg?
- Get updated meta value after post update or published (custom post type) using hook
- Show preview of post changes on page
- Add Metabox to settings / options page
- custom-meta-box checkboxes from loop won’t save
- Undefined index error in custom post metabox
- WPAlchemy MediaAccess inserting media link in WP Editor instead of custom field in metabox [closed]
- Meta Box will not display
- My custom write panels won’t save data. What am I missing?
- $_GET & $post_ID
- How can i use this meta box function in my template ? (WordPress)
- How to disable Author dropdown in Gutenberg’s Status and Visibility panel
- Display stored value in Meta Box
- Display Content if custom meta box checkbox is checked
- How to add meta box for current post format?
- How to check specific value in two metabox?
- How to show taxonomy terms from wordpress database?
- Error showing in current page id in wordpress admin
- Show value of select dropdown in meta box
- Output list from each line of metabox (shortcode)
- Hybrid meta box, how to show?
- Understanding WordPress’ post type support
- Include doesn’t work, getting strange path: (/usr/local/php53/lib/php) – Whats wrong? (WPAlchemy)
- wordpress alchemy put custom metabox on certain page only
- using WPalchemy to output custom metabox from homepage template
- Custom meta box data in rss feed
- How using the Meta Box plugin, to filter posts by the value of a post type field?
- metabox dosn’t save with checkbox of post_type values order by taxonomy
- save meta data of custom post type: WP_Error has no effect, even if insufficient capabilities
- Is there default meta boxes types that handles types and sanitization?
- how to update editor content from metabox
- Resposive admin classes?
- Only allow one meta key value per post in a category
- Make metabox always be on top (sticky)
- add_post_meta Adds post meta but the value is blank
- Customer portal (posts as checklist)
- Option to delete value in metabox
- Remove Title, Editor and Meta Box Support Based on Post Formats
- Custom select box meta field
- Saving an upload media meta box field
- Is there a way to remove the Add boxes from the Screen Options menu metabox?