Now in saving function …
in which hook ? if you do this in “save_post_CPT”, it doesn’t work because this hook is called a first time a the object creation
then you have to do this :
add_action("save_post_CPT", function ($object_ID, \WP_Post $object, $update) {
if (!$update) {
// new object, here you can define default values
return;
}
if (isset($_REQUEST["uniqueid"])) {
check_admin_referer(
"uniqueid"
, "my_nonce"
);
// saving informations of the metabox
}
// here the code when the object is put in the trash or with quick edit e.g.
}, 10, 3);
Related Posts:
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Do I need a nonce field for every meta box I add to my custom post type admin?
- Help Creating a Slideshow Custom Post Type with Custom Meta Boxes?
- Custom Post Type – Taxonomy Dropdown Menu?
- How can I add a column/s to wp_posts table?
- echo value from ‘select’ field type into page template using cmb2?
- How to get custom metabox image field?
- Detect meta value changes when post is updated (post_updated)
- Custom field being erased after autosave
- Order custom posts by a date metabox
- How to select one major category (or custom taxonomy) for a custom post type?
- How to sort CPT by custom meta value (date), and return posts month by month
- Use Custom Post Type as Custom Field
- Saving multiple Metabox contents
- Undefined index: at_nonce in custom post metabox
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Metabox saving values
- add_meta_box: Datepicker like the one for postdate?
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Displaying Meta Box Image
- Multiple information using custom post type
- how to set default value for checkbox in wordpress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Display custom post on home page based on a metabox selection
- Security checking in meta_box save is reluctant?
- Why do I lose the content of meta boxes when I leave the page?
- Dynamically add / duplicate custom meta in custom post types
- WordPress custom meta field for custom post not storing data
- How to Duplicate (multiple meta box)?
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- List of Posts in a Custom Field
- Save an array from drop-down in custom meta box
- Populate Custom Fields in a Custom Post Type?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta
- Keep display metadata value on backend – Custom Metabox
- How to check if user meta field is empty in conditional else statement
- Why is my select meta data not saving?
- dynamically add a custom field or metabox to custom post type [duplicate]
- Visual editor issue by having multiple tiny mce editors in a CPT
- A better way to add a meta box to custom post types
- Plugin – Combine Meta Box Input Fields into single saveble record
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Grouping metadatas into one
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Cannot save CPT meta box
- Adding Page Templates to post but it ignored it
- Permalinks: custom structure for taxonomy – tags?
- Custom “radio button meta box” not saving correctly
- Add additional field to custom post_type
- Custom Post Meta from custom metaboxes is randomly being deleted
- Add a custom meta box for client to order CPT posts how they want
- Display Repeatable Meta Box Content
- create custom meta box with default value
- What do the numbers mean at the end of add_action(‘save_post’)…?
- A meta box (in a custom post type) with two different type of fields
- Forms and WordPress Nonce
- Reusable metabox backend and frontend
- Get custom term meta problem on single post type
- Display custom meta on page that has been check in custom post type
- How can I output WPAlchemy repeating fields meta values in my page template?
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- Adding an extra parameter [string] to my posts’ permalink?
- Problem On Retrieving Post Meta Data on Custom Column [closed]
- Add a class to post_class if more than one post shares same meta_value_num
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Saving metabox keys and storing values as array
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to avoid duplicate posts queried from custom meta?
- Custom Metabox Info Not Saving
- PHP Warning with Custom Fields
- Problem with multi checkboxes value in metabox?
- Simple Data picker meta box
- Avoid another meta box in my custom post type
- Delete custom post type metadata without deleting the post in admin area
- Search form to find custom meta box generated data
- Filter CPT based on meta box value using Flexible Posts widget?
- Textarea type on one field custom add_meta_box?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Extending a CPT by Created by another plugin
- Custom meta box includes
- Creating entries with image attachements within posts and managing them in a list
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Adding a custom “Add Custom Field” button to Custom Meta boxes
- Display div based on Group metabox selection [closed]
- How to consume external API from WordPress post editor and display the response data in the custom field?
- WordPress metabox file upload in custom post [duplicate]
- How can I dynamically add a post to a custom post type which uses a custom field?
- Show fields based on taxonomy selection in editor
- How to Get the title of a custom field?
- How do you output an unknown number of images in a custom post type with desired markup?
- Function to return values from metabox
- Wp Meta Query does not work while simple Query Works
- How to add dynamic fields on wordpress custom post type page in admin section
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Adding a custom field after post title (ex.Example Title [30 Second Read])