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
- Custom Post Types, slug, archive and SEO plugins
- get all posts ID from a category
- Manipulate post category after time
- How to enqueue scripts depending on post formats?
- How to add a custom field after wp post
- How to prevent WordPress from updating the modified time?
- Dynamic carousel on individual posts
- Prepend or add an Image to the content of a Post
- Remove all links in post content
- I get this error message when I try to add a module to a course on my website using Sensei plugin
- Get all comments of author’s posts
- Get posts and include taxonomy term
- Two Custom Post Types with Identical Articles Competing for the same Slug
- Single Post in Tab/Slider
- posts_per_page returning only one post
- I can’t find the relevant part of the loop in my theme file. How do I find the full content with “More…”
- How to change the order of elements within a post?
- Right align a youtube video
- Css and function issue on author archive page
- How do I fix broken links to images in imported posts’ post_content?
- Get post attachment with post id
- How to show random post order in specific category each refresh this category page
- how to make special modal for each post
- Get post id outside loop : Notice: Trying to get property of non-object
- WP_Query to get posts in a specific tag or has post_format
- Pagination for single post
- Add caption to thumbnails in content
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Theme does not respect spaces between paragraphs in pages
- exclude one child by id from $post->post_parent
- Continuous listing from a custom field
- Text editor has problem with having ” in a post
- Getting posts from multiple users?
- Stripping tag from elements in post
- find view post hyperlink in PHP wordpress admin file
- Even/Odd every two posts
- What function does the loop of displaying posts?
- WordPress Post Updating is Not Working