Do the check inside the callback. save_post will pass you both the post ID and the post object:
do_action('save_post', $post_ID, $post);
So…
function save_my_meta_box_to_postmeta($post_ID, $post) {
if ('yourtype' === $post->post_type) {
echo '<pre>';
var_dump($post_ID,$post);
echo '</pre>';
die;
}
}
add_action('save_post','save_my_meta_box_to_postmeta',1,2);
You may want other conditionals as well like !DOING_AJAX, for example.
Related Posts:
- Correctly delete posts with meta and attachments [duplicate]
- Storing revisions of metadata for custom post type
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- Ordering posts having multiple post-meta date fields
- Custom Post Type with Input fields to seperate table on database.
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- How Can I save multiple records in same meta key?
- Permalinks using event date (year & month) instead of publication date
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Creating a custom post type upon registration
- Reason action hook won’t work with update_post_meta from frontend form? Alternative?
- Showing Meta Data for Custom Post Types?
- Having trouble with custom post type / meta box
- Query for posts from any post type but only add instock products
- update custom post type meta from a shortcode
- Custom post type category not displaying in custom post type
- How to make custom post meta wp_editor translatable?
- How to keep a check box in custom meta box for custom post type checked by default for add new post?
- How to add multiple featured image in meta box in post editor?
- Show metabox in custom-post-template depending on taxonomy term?
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- update_post_meta() whenever custom post type is updated
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Using date stored as custom field to filter posts displayed in admin
- Meta Box Only in CPT Edit Page, Not in Add New
- get_template_part() – post-meta not working?
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Populate Custom Fields in a Custom Post Type?
- Insert Multiple Post with Same Publish Button
- Custom meta box data array: foreach not working correctly?
- Undefined Variable – Custom Post Type Meta
- How to check if user meta field is empty in conditional else statement
- Post image in WordPress not appearing on home page
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Getting meta in editor plugin, and event triggering issue
- Should wp_postmeta meta_key always be unique for a given post_id?
- Metabox not show in categories custom post type cmb2
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Custom fields for custom post type
- Filter date from post meta when date is in string format
- Get only used meta_values
- Is there a way to exclude posts based on meta_values?
- Submitting Custom Post Types with custom fields from Front-end form
- Get $post->ID from a URL
- Displaying a div from an assigned meta_value when on a page
- Setting Post Title via Meta Data returns Auto-draft
- How to Echo Metadata Value in Currency Format
- Filter posts by tax (dropdown) and meta value
- Batch Extract Date from post title and put into ACF custom field
- How to handle this specific case of custom post type?
- Save CTP post meta different values each day without overwriting previous values
- get_post_meta returns NULL in front-end, but correct result in back-end
- Meta box data is saved but NOT displayed in the meta box text field. Why?
- How to call a post’s metadata in shortcode.php?
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- HM CMB: Post Select Field for CPT ID
- Getting WordPress to store 0 values for custom post type meta
- Problem Saving Custom Post Type Meta Values
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Get_post_custom not fetching value from array wordpress
- Save data is post using php front end
- Creating a custom post type upon registration for a specific user role
- How to sort by multiple values in a nested WP_Query
- Peepso: Add extra data field (custom post meta) to postbox
- Where is get_post_meta value located?
- How do I create a customised table list of a custom post type (in the admin area)?
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- add action save post type and update post meta woocommerce
- get_post_meta not working with variable as a post_id for dynamically get the postid
- How to save post_status using action save_post?
- Custom post meta box as a sub form
- Metaboxes in Loop
- Add more custom fields when creating a new custom post type
- Custom meta box data not saving
- Collect custom post in a calendar
- Storing data in a multidimensional array from dynamically generated foreach loop
- Disable Facebook Comments Automatically On CPT
- Problem with ‘save_post’ hook not running
- WordPress custom post type
- Edit post meta direct from post.php?
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Values inside a custom field to determine which category posts to display
- How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
- Change the contents of a dropdown through the admin panel?
- Advanced search form with filters for custom taxonomies and custom fields
- Top 30 Songs using Custom Post Type
- Advice Needed for Post Meta Database Efficiency
- Querying meta values within an array
- why get_post_meta is returning 0?
- Save post_parent in a custom post type
- Update an existing post in a custom post type
- getEntityRecords/useEntityRecords: How to use CPT metadata?