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
- retrieving external api data and updating existing custom post
- Possible to hide Custom Post Type UI/Menu from specific User Roles?
- How do you use a CPT as the default home page?
- Custom post type, no need for single view, plus want permalink rewrites that include hash in URI
- Custom Loop for Custom Post Type
- Custom Post Type Permalink Page Not Found
- Add custom column at custom posts list
- Pagination in plugin with custom post type
- Managing event dates vs published dates in admin custom post type
- Adding Custom Taxonomy to WordPress default Post type
- Adding description to archive of Custom Post Type
- How do I include drag-and-drop in a plugin?
- Programmatically adding posts
- Conditional to modify query results
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- Get rewrite slug of custom post type in template
- Use WP_Query() to Output the 4th to 6th Most Recent Posts of a Custom Post Type
- How can I add another option to this custom post function?
- Restrict user to only one custom post type
- How do I get the intended post type of a revision post?
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Custom rewrite rule for hierarchical custom post type
- Page template with different page and post content
- Custom Post Type with archive page but no detail page
- Custom Post Type with image gallery
- Custom post type url with category
- Display featured image from one CPT within another CPT query
- Show titles, date of all posts on single category page
- Remove slug in URL custom post type
- How to restrict author to only access one custom post type ?
- Not sure if I should create multiple custom post type [closed]
- Can NOT search my custom post type?
- Why won’t this jQuery code work?
- Category archive in with conjunction with custom post type is empty
- Custom post doesn’t show featured image
- Create field of Custom Post Types
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- Pagination hitting 404 page on /page/4
- Custom Meta Box returns no HTML
- Save Metabox Custom Field Value
- Multiple Loops on a Page Without Duplicates
- get_post_types not working properly in admin
- How to hide a custom field from admin?
- Get the latest comment from a custom post type where depth = 1?
- Custom Meta Box with variable number of fields
- Specifying a template for custom post type pages
- Custom Post Type, Pagination and 404s?
- Do post types share the same records using the same taxonomy?
- Display another page / custom post type as home page
- Action on Custom Post publish
- Post template not applying on theme (potentially rendering as Page template)
- Problems in paginate_links with custom query loop and MB-Relationships
- Trigger WP CRON from a date in a Custom Field?
- posts_per_page is not working by term
- Filter Custom Post Type Posts by Taxonomy
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- Autofill advanced custom field with user data
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Why does my plugin require a permalink reset after a new installation?
- Limit Number of Custom Post Type Dashboard
- Reference field of users in custom post type
- Avoid another meta box in my custom post type
- Not Able to Get Custom Post Type in Single and Single-custom-post-type
- Get posts of an specific term of a custom taxonomy
- WP_Query return highest number only
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- Add a meta to custom post type which corresponds to a particular taxonomy
- Get custom taxonomy name from custom post
- Nested custom post types templating
- Hook only specific post type
- custom post type and taxonomies in a php class
- Storing postID in session variable to query database when visitor on custom template page
- Create a Page Templete to Display Table Of Content for Custom Taxonomies
- send user to first page of results when reposting to page?
- How to create a job post by email parsing? [closed]
- Sort ACF by custom taxonomy
- Custom Post Type posts not getting picked up in archive widgets
- Is it possible to get_terms by taxonomy AND post_type?