You could also hook into the save_{$post_type}
action, which fires only when a certain post type is updated. This hook passes to post’s ID to the callback function:
add_action( 'save_post', 'my_callback_function' );
function my_callback_function( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
// Unhook this function so it doesn't loop infinitely
remove_action('save_post', 'my_callback_function');
// Update post's data
$post = array(
'ID' => $post_id,
'post_date' => current_time( 'mysql' ),
'post_date_gmt' => current_time( 'mysql', 1 ),
);
// Update the post, which calls save_post again
wp_update_post( $post );
// Re-hook this function
add_action('save_post', 'my_callback_function');
}
}
Related Posts:
- Elegant way to include only published posts with get_objects_in_term()?
- Prevent scheduled post being published if date/time is past current date/time
- WordPress bulk category select when publishing post
- add action only on post publish – not update
- How to prevent posts from being published too close to each other?
- Different post sort order within different categories
- Displaying the category name of a custom post type
- How to schedule multiple posts while adding new
- Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- WordPress plugin to publish to multiple remote WordPress blogs
- How are terms connected with posts in database?
- In what sequence are the hooks fired when a post is “published”?
- Convert IPTC keywords to blog post tags
- Add javascript when post is published
- featuring old articles without messing up with the archive
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
- Publish posts only after the condition is met
- Hiding by default specific post status on backend list?
- Detect Post Type when publish_post is ran
- How can I display a specific user’s first published post?
- deleting terms programmatically
- Prevent post from being published if no category selected
- Send email to user that his post has been rejected
- Adding Multiple Values to a Post Meta Key
- How do I get the slug of a custom taxonomy category of a post?
- Post taxonomy from exif data
- Using Custom Posts with Metaboxes and Drop-downs
- How to insert current date/time in the content of a post?
- Does an action fire when adding a tag via the “Tags” meta box?
- Every possible way to get data (posts) from WordPress
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- How to get the date of a post in WordPress, so I could use it in a script?
- disable column on post and user list
- Notification to Admin or Author upon new post [duplicate]
- What differences are there between a Privately Published post and a Draft post?
- How to run a function when post is edited or updated using publish post action?
- How to rename “Publish” metabox title in post screen
- count the total number of comments the user has received for his published posts
- Get posts by name and taxonomy term
- How can I schedule a PAGE to go live at a future date/time?
- How can I show many posts an author has per week?
- Get posts of ONE taxonomy term of custom post type
- If modified on same day, show only time
- Force the “Choose from the most used tags” meta box section to always be expanded
- Decide user that can publish a post
- How to switch wordpress post status between publish and schedule in MySQL?
- Posts list in custom taxonomy
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Prepending %category% onto default posts fails
- get_adjacent_post by language
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- How can I setup a relationship using categories in WordPress?
- How to display posts via custom taxonomy terms using checkboxes?
- Copy post to separate database with “add_action(….)”
- 404 error on default post type and default taxonomy fronted page
- How i can limit period of post publication?
- How do I manage my users post before publish?
- do more action after I publish a post
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Loop parent terms {display posts} AND loop child terms {display posts}
- Assign published posts to another user automatically
- Changing default WP-Site creation date
- Is there a query string for edit.php to show all posts that have no custom taxonomy terms?
- Display password protected posts to logged in users
- tribe_get_start_time displays the current date and time on other post types than tribe_events
- Get the most recently modified post date of most recently modified post
- How to show different timestamp
- Post: how to set created date after post has been published [closed]
- Publish a Silent Post without updating Feed
- How can my plugin display a populated new post window
- Access last visit time to a post
- How to output all taxonomy links from a custom post type in a menu?
- Geting error in post and category [closed]
- Custom post type and taxonomy page templates
- Post navigation using date
- How to display the post categories for each post inside the loop with custom format?
- Bulk update published posts date randomly using wp-cli?
- Hook when post is set from published to draft?
- Send email to user when I publish a new post
- Post not using taxonomy template
- WordPress get tags in “publish_post” hook
- Create/Set Category as Title of Post
- post is not showing more than 3949 words
- Page with Category Returning 1
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- wordpress display posts by terms id or name
- Custom Taxonomy From Database
- How to list all names and descriptions of a custom taxonomy
- How to Test a Blog Post for Update vs. Publish Status — Unique
- How to handle a post before publishing?
- How to get all the terms of a post
- Special Query: Title, Terms, Content – %LIKE%
- retrieve post slug by post_tags taxonomy
- Return All Post from publish to draft [duplicate]
- Action while post is being published
- How can add custom commands in post-new.php in wordpress
- Filter/Sort Post Form On Taxonomy page
- date_query returning only the most recent post instead of the post published before today