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
- WordPress as microblog: show excerpt instead of “(no title)” in posts view
- Comment count next to post title?
- Get WordPress post content by post id
- Get page ID of page that is set as the posts page
- Get Posts Under Custom Taxonomy
- How to limit the number of posts that WP_Query gets?
- Stop WordPress Wrapping Images In A “P” Tag
- When is the ‘post_content_filtered’ column in database cleared by WordPress?
- Turn a URL into an Attachment / Post ID
- GET the excerpt by ID
- Stop WordPress automatically adding tags to post content
- Determine if page is the Posts Page
- How to get ‘post_content’ without stripping tags?
- Hook for post and page load
- How to add an admin notice upon post save/update
- Print Current Post Index number within Loop
- Should we trust the post globals?
- Optimize post insert and delete for bulk operations?
- Get the Current Page Number
- How do you add thumbnail support for custom post types?
- How to mark every 3rd post
- Change Posts per page count
- Keep featured content post in homepage with original order
- How to display related posts from same category?
- Can posts have parents?
- Is there a action hook for the “Empty Trash” button?
- How to end the excerpt with a sentence rather than a word?
- How do I check if I linked to a post before I delete it?
- How to change the case of all post titles to “Title Case”
- Appending content with broken in 4.4
- How to get posts published between a date and today?
- ZIP up all images displayed in a [gallery] and offer as download link
- How to detect single.php (but not single-portfolio.php)?
- How to check if post meta key exists or not in wordpress database
- How to remove a column from the Posts page
- removing inline styles from wp-caption div
- What is the use of to_ping and pinged column?