The action sends the $post_id
just like you have so that’s not the problem.
Have you tried a var_dump
of $_POST
to make sure it’s actually posting something other than null?
Also, using the save_post
action is going to be called every time a post is saved, so you probably need to use the save_post_{custom_post_type}
action, replacing {custom_post_type}
with your actual custom post type (if it is one).
You could try this:
function process_image_meta( $post_id, $post ) {
error_log('POSTED: ' . $_POST['upload_image_id']);
$result = update_post_meta( $post_id, '_image_id', $_POST['upload_image_id'] );
error_log('Image Meta Added: ' . $result);
}
Make sure you have this in your wp-config.php
:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
Then check the /wp-content/debug.log
file for the output
Related Posts:
- frontend image post uploader
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Allow authors to create article image
- How to disable generation of default image sizes for some custom post types?
- Removing Image Sizes for Custom Post Type
- Image size filtering in Media uploader according to custom post type
- How to get source of custom meta image?
- Stopping WordPress from Auto Generating Image Files for Sizes
- How to rename image at uploading on specific plugin or post-type in WordPress
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- List all images from a single post meta value
- How to Create an Image Upload Box for Custom Posts?
- Redirect to another page using contact form 7? [closed]
- How to add multiple images to a custom post type without plugin [closed]
- How do you output an unknown number of images in a custom post type with desired markup?
- copy images from custom field to another custom field
- Should i use custom post type for a custom footer?
- Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
- How to Create a Frontend Html-list Editable in the Backend?
- Custom Taxonomy dont save in a frontend form for post a custom post
- Add Extra Category Field to CPT Categories
- Search CPT Title AND Meta
- How to prevent meta data from being edited in a post?
- Update custom field value
- Cannot upload featured image to a custom post type
- updating one custom meta field only
- Automatically add a character to field in edit post page
- Save Custom Fields
- Problem On Retrieving Post Meta Data on Custom Column [closed]
- Change Post Meta via AJAX from the posts list table
- Cache issue with WP_Query and custom field filtering
- Insert custom fields to a custom post type
- Display Posts Query with IF function
- Thumbnails Not Generating
- Add a class to post_class if more than one post shares same meta_value_num
- Excerpt length: get first paragraph
- Image upload and path to custom field
- Get post-meta value of all custom-posts – lowest to highest year-count?
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- How to keep a record of changes to a custom field?
- Fill custom fields when saving custom post types
- Invalid file type when using wp_upload_bits to upload PDF to a custom post type
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Insert into post button missing on custom post type
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Order custom posts by taxonomy, then by meta_key
- Adding a Custom Field to be used by Posts 2 Posts
- Custom field only on custom post type?
- Returning an image url from its attachment ID using a custom post type plugin
- Saving metabox keys and storing values as array
- Custom PT, Taxonomys and wordpress query
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Front-end Image Upload to Custom Meta Box
- How do I list a custom field and custom taxonomies for each result in a loop?
- Writing a custom Glossary plugin
- How can i loop through custom post type according to custom meta field?
- How to use get_post_custom_values to return the value of an array
- Filter search posts by post meta?
- Problem with date comparison for custom fields
- Use Gravity Forms and a Shopping Cart for output to Freshbooks for an Estimate [closed]
- Create list from custom field comma separated values
- How can I sort the order of multiple custom field values in a custom post type?
- CMS – User confusion when creating new page and having to select template and save first to see correct fields
- Checking for custom field in admin pages
- A sports wordpress website
- Mandatory field in Custom post
- How do I ensure that post_type and Taxonomy use the same slug?
- Images not load on custom post type sidebar, related posts
- How to make an API call to a custom post type but filtering by meta value?
- add_filter get array data before display in custom post_type
- Not Able to Add New Class To CPT Attachment Image
- Migrate Custom Post Type with Custom Fields data and parent child order
- Update value inside array update_post_meta
- WP query_posts group by meta field related
- Get previous and next custom post by custom field
- Custom fields for post or terms which don’t update on post update
- Display custom post front end filter by ACF equals current user
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- order the meta query results by 2 custom fields
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- Custom taxonomy terms as children of multiple custom post types
- ACF – Retrieve custom taxonomy from a relationship field
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- How to store the third party script with HTML code in the wordpress custom input field?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Custom Form / Search with Custom Post Type Data
- Custom fields array to display it monthly
- Copy data from 2 different ACF custom post types with relation
- Creating a custom page post type just like the original “pages” post type using CPT UI
- Adding a location field to buddypress activity
- how to skip a CPT element from the pager by custom field
- Create if else for post types in WP_Query ‘post__in’ values
- WP Query from two Custom Post type fields as statement
- How to Print Title and Permalink of CPT Post behalf of Posts Meta Value with WP_Query
- Alike Shortcode using in Custom Shortcode