If it doesn’t work you can try to use a wp_insert_post action:
function insert_post_hook($post_id, $post) {
if ($post->post_date != $post->post_modified) {
// This post is being updated!
}
else {
// This post is being created!
}
}
add_action( 'wp_insert_post', 'insert_post_hook', 10, 2 );
If you want to see the latest version you could enable revisions:
define('WP_POST_REVISIONS', 3 );
This will save a maximum of 3 revisions.
After enabling you can check the following:
$latest_revision = array_shift(wp_get_post_revisions($post->ID));
Related Posts:
- Hook that get’s triggered when the author of a post is changed
- The hook for the AJAX Add to Cart button?
- Get old values for post before saving new ones
- Execute function when post is published
- how to limit edit_form_after_title hook to page and post edit only?
- Action hook ‘wp’ firing twice… why?
- In what sequence are the hooks fired when a post is “published”?
- Better post meta efficiency?
- Count singular post views automatically
- How to change post status from publish to draft using hook in wordpress?
- Filter post before *editing*
- WordPress Delete hook with wp_delete_post function?
- Custom function for “Submit for Review” hook
- First hook to use current page post id
- How to place HTML below the title of the (custom) post overview
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- Does an action fire when adding a tag via the “Tags” meta box?
- Are posts updated or built from revisions + autosaves?
- How can i do something after head like adding a hook for after head but before post
- Action hook for new pending posts?
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Register post status, exclude from searches
- How to modify post content?
- Which WordPress hook fires after post content loaded?
- What is the filter or hook to add admin controls to posts on the front end?
- Adding buttons to Add New Post and Add New Page
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Hide a specific category in admin All Posts page (WordPress)
- How to access $post from a callback function
- Updating post data on save (save_post vs wp_insert_post_data)
- Copy post to separate database with “add_action(….)”
- Hooking into the post editing screen for an existing page only
- Trying to alter the post_content through the_post
- Call Web Services on post first publish
- How to dynamically parse and transform post/page content before displaying it?
- What does WordPress do if I save a post without content/title? [duplicate]
- Adding bootstrap classes to video shortcodes
- preg_replace not removed “class”
- why the same code got different results when using query_posts in functions.php and index.php
- Divs appearing everywhere in post content
- Modify posts listing at back end
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- Automatically set post_parent value
- Posting to WP via URL
- Is there a way to know when a page has been updated and do some action only once?
- Restricting displayed posts to posts from only select authors
- How can I change the date format of the revision list?
- Hook when post is set from published to draft?
- Is update_post_meta used when save_post action hook is invoked?
- Get Category in save_post Hook
- Count singular post views automatically
- How to prevent post update using transition_post_status
- Grab meta data before post is saved
- How to get the postID inside ‘content_save_pre’? Other hook?
- wp query custom orderby not custom field
- How to remove related post from home page
- Checking if some condition is matched before inserting post into database
- fire action when post is being edited as well as saved?
- Which hooks are essential for post templates?
- save_post not working
- Admin notice on wp_insert_post
- Modify upload directory to use post category slug in file path on multisite installation
- Comment count next to post title?
- How to retrieve text only from wp_content() not from wp_excerpt()?
- Add existing images from Media Library in to custom gallery
- Limit on the max number of words per post?
- WP_Query to work with custom view
- Get the user type of an author
- Order Posts by Alphabetical for Each Letter
- Restrict access to the Trash folder in Posts
- Post custom permalink results in 404 for archive page
- Check if Currently on Static Posts Page
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- How do I get the slug of a custom taxonomy category of a post?
- Featured Posts for Category Pages
- Hiding posts in a list from specified categories
- Disable Post/Page comment emails for creators
- Define a name to the posts slug
- Get post id in wordpress action?
- How many post WordPress can handle?
- Create an article from another Java application
- Display most recent post in full, excerpts of older posts
- The post loop doesn’t work
- Buddypress activity id
- Tags to Post-ID mysql query. Tag Search
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Display post from current category and same tag?
- How to include a post type in the admin/backend?
- Can I use images as anchor tags with
- How to get post bulk edit action trigger and get edited post ids?
- Paginated Posts – Social Media Buttons Share First Page URL
- IP camera jpg stream to post
- Is there a straight-forward way to iterate over all shortcodes in a post?
- Using custom post template
- Adding custom fields to bbpress reply form
- Display post option on frontend
- Post id algorithm in WordPress
- Show the content that is after the excerpt using child theme
- Skip in WordPress Post ID’s, can this cause issues?