Using your example link, I just added an IF to check for post_type.
function reset_post_date_wpse_121565($data,$postarr) {
// var_dump($data,$postarr); die;// debug
if($data['post_type'] == 'new_cpt'){
$data['post_date'] = $data['post_modified'];
$data['post_date_gmt'] = $data['post_modified_gmt'];
return $data;
}
}
add_filter('wp_insert_post_data','reset_post_date_wpse_121565',99,2);
Related Posts:
- Automatically fill custom field value on post publish/update
- wp_update_post on specific custom post type
- wp_update_post based function works on existing posts, but not new posts
- Updating post title using wp_update_post
- How Can I Set the Post Author of a Post I Just Created With PHP?
- Insert and then update post_type by wp_update_post
- Posts are duplicating on wp_post_update
- Post author for revision not being set on update/insert
- Programmatically change post visibility on save_post action return a 500
- Why does wp_update_post causes white screen?
- Update post if exist from PHP
- Odd behaviour for the update button when displaying a WP_List_Table
- How to keep a record of changes to a custom field?
- Updating a custom post status after an expiry date rather than trashing it
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- update flamingo_inbound post type after insert
- save_post affect creation and deletion
- Can I override the permalink/slug on creation
- Custom Post save causes 500 error
- Change custom post status to draft before today
- Exclude from search all custom posts which are NOT in a taxonomy term
- Remove tabs from media uploader for a CPT
- Remove unwanted part of permalink custom structure from CPT url?
- Changing a custom post type “has_archive” after registered
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- wp_insert_post custom taxonomy
- dynamically update permalink and title with the values of custom fileds
- Parent page for CPT
- Unable to get wp_redirect() working after adding a CPT via the front end
- Post Link Filter Help [closed]
- Append taxonomy terms as class names in markup?
- Custom Post Type “Event” with custom permalink structure
- Getting a “Changes you made will be lost” dialog prompt on a custom post type page
- Custom Post Types vs Database Table where many (10,000s + ) of entries are possible/desirable
- How to associate two different post types (think Book and Chapter)
- Permalinks without post type
- Different Archive and Single Permalink URL
- How to remove slug metabox from custom post type’s page?
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- is there a way to retrieve posts that do not have a featured image assigned?
- How to structure sales of reports [closed]
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Custom Taxonomy Permalinks Redirection
- Undefined Variable – Custom Post Type Meta
- shortcode to show custom post types by category
- Custom post type archive page template
- filter custom post type by meta key in dashboard
- Use a hierarchical custom post type for a main blog and subblogs?
- get custom post type
- WordPress Custom Fields Won’t Save
- Getting meta in editor plugin, and event triggering issue
- Display a grid of taxonomy terms at root taxonomy page
- Only show post if Author matches Logged in User
- posttype/taxonomy/term archive page 404 error
- How to add attributes to taxonomies that may be different from post to post?
- Add additional field to custom post_type
- Is it possible to filter the display name for post formats for display in the Formats meta box?
- Conditional for a Single Post That Belongs to a Category?
- Creating my own portfolio custom-type
- Dynamically output a class to an anchor tag depending on what tag is chosen
- Implementing Pillar Posts; Long Posts yet with Some Page-Like Handling?
- CPT Columns doesn’t show categories
- Custom Post Type “MUST NOT” be able to search via URL
- Custom taxonomy template list not working (404)
- Query for post and costom post_type in same category filtered by meta for post_type
- List latest post out of 2 custom post types
- Adding custom post formatting options in custom post types
- Adding Page Ordering to a Custom Page Type
- How to properly use Categories with Custom Post Types
- Better in the long run to use post date or custom taxonomy to sort/separate posts by year?
- Get post-meta value of all custom-posts – lowest to highest year-count?
- One Custom Post Type two different Templates
- Custom Post Type Query W/Category Dropdown
- On click some element i want to use some template
- Pin posts to top of custom loop
- Remove custom taxonamy slug with pagination
- How do I link to a dynamic ACF button from a Custom Post type?
- Hook create / update post
- Show Post columns to specific users on condition
- Change picture attachment meta of all occurrences of a picture
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- How to use costum database table for custom post type
- connect users to Custom post types
- Making my custom column sortable
- date_query won’t accept day parameter, but will accept month and year for a custom post
- the_permalink() leads back to homepage
- Custom Post Type Pagination Not Working or Single Posts Displaying?
- 404 error Custom search results page for custom post types with friendly URL
- Custom metabox value not saving
- Category / Custom Post Type permalink issue
- is_singular won’t call my functions?
- loop through custom post-type with two meta_keys
- How do i make a listing page of custom post type?
- How to add post type in masonry posts elementory widget
- How to exclude certain portfolios from a loop
- Add post id to url instead of WordPress default -2 suffix
- How to consume external API from WordPress post editor and display the response data in the custom field?