You can simplify your save handler by checking if the POST variable is set. If it isn’t, no need to handle the request:
function save_files( $post_id, $post ) {
if( ! isset( $_POST['image_upload_nonce'] ) || ! current_user_can( 'edit_post', $post_id ) )
return;
// Good to go, handle everything.
}
For an explanation on why the save_post
hook is firing, see my other answer.
Related Posts:
- How to set a custom post type to have viewable future posts
- Loading Custom Post Type Events into jQuery-based FullCalendar?
- sort events based on event date custom field
- 1 day after custom date change post status to draft
- Custom Post Type Events Archive Grouped By Month
- Save metadata as a timestamp, display as a “pretty” date
- Display upcoming Events for next 7 Days
- CPT EVENT – listing by month and filtering by category and month – form select option
- Creating a Custom Post Type and Joining with Users
- Select event where start date is smaller than current date and end date is greater than current date
- List of all entries of custom-post-type: Add year-parameter?
- Sort custom post type by most current date picker
- Should i use a plugin for Event Manager or code my own needs? [closed]
- Empty meta-box returns publishdate if no value is set?
- Event Archive by Month
- how to compare different timestamps in wp-query for events custom post types?
- Creating an Events Feed with Sub Pages/Posts for Each Event
- Yelp-style geographic directory plugin?
- How do I list the next 7 days and any events (cpt) contained in those days
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- connect users to Custom post types
- Query events post type after current date and timezone
- Loop posts in a table ordered by a custom field value
- Custom Loop Event Page
- Add role privileges of the custom post type
- Events with multiple event dates + permalink for each date
- Query Event Posts by Date
- Listing future posts together with normal posts
- Unable to sort wp_query by date/time with multiple meta_key s
- Count of posts with meta_key filled in?
- How to print different informations for different post types inside The Loop?
- What would be the optimal CPT / Taxonomy design for the following entities structure
- Can I change a custom post type label from a child theme?
- Get category id from post id of a custom post type
- Custom Taxonomy as Dropdown in admin
- Hide custom post type field from author?
- How to disable a Custom Post Type Feed?
- Permalink for CPT with taxonomy
- order of date column in custom post type
- How to create custom URLs for Custom Post Type sub sections?
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom post type category, taxonomy and URL rewrite problem
- Trying to save custom post type from frontend partially working
- Dropdown list of a custom post type
- How to use different featured image size for a custom post type?
- How to display recent / random posts by its category
- Good way to store content and settings for an RSS plugin
- Exclude specific taxonomy term when using wp_get_post_terms
- Custom Post Type with metaboxes (no content) only?
- Querying Term Posts in Loop
- Can’t get order_by meta_value_num to work properly
- Post Type Description for ‘Posts’
- One-to-many post relationships that are displayed by category (using posts-to-posts plugin)
- Conditional Statement custom post type category
- will post_id ever change? Can I safely use post_id for custom queries?
- Custom post URL 404 error
- Add Custom Post Type as top level menu item for a custom page
- don’t publish custom post type post if a meta data field isn’t valid
- How to handle large number of images in a post?
- get_the_post_thumbnail_url(‘full’) returns empty from custom post type
- Proper way to display latest 5 posts grouped by post type?
- How to set up Custom Post Type archive page as Front page
- Give each post type label a different color?
- Custom Permalinks For CPT and pages with parent. Advanced WordPress
- CPT is simply not displayed in the main archive with “pre_get_posts”
- How to display hierarchical and non-hierarchical taxonomies?
- Can’t access private custom posttype single- or archives-page
- Modifying the default post from wordpress
- Cannot obtain custom meta information
- Plain links in single-class.php and archive-class.php not working
- How can I get 3 different taxonomy type terms in a div class element?
- Searching post types
- wordpress post_where set only for my costum post type
- Looking to Customize YouTube Video Embeds
- wp_query not returning my custom post
- Using page title as a link to term archive
- best way to use custom taxonomy, post type and meta in a job system
- Pagination on a page
- Display category name of custom posts only once in the loop
- Virtual page and loading template
- Template for Custom Post for the EDITOR
- Restrict admin pages for specific user role
- Custom attachment function not working in v5.4.2?
- Help understand and create a loop with WP_query
- PHP Warning with Custom Fields
- Don’t share custom taxonomy terms if applied to multiple Custom Post Types
- How to show custom post count in archive page
- filter rest api post by a acf filed
- How can I prevent the admin to create a new custom post type more than one?
- Custom post URLs
- I want to show specific parent terms child term with post list
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- How to use wp query posts with current post meta value in text widget
- category page template for custom post type
- Delete attachment with post
- Get link for feed of specific post type AND taxonomy
- Copying custom field value in to title
- Get single object term for custom taxonomy
- img src not working correctly in custom post type
- How to consume external API from WordPress post editor and display the response data in the custom field?