save_post
Runs whenever a post or page is created or updated, which
could be from an import, post/page edit form, xmlrpc, or post by
email. Action function arguments: post ID and post object. Runs after
the data is saved to the database.
above paragraph is quoted from WP Codex.
so you cannot use this hook to get older value because it fires after saving new values to DB. WP has another action hook named wp_insert_post
but sadly this hook does same thing as save_post
alternatively you can use Filters to get the job done. WP provides few filter to edit the post while saving or before saving to DB. like wp_insert_post_data
& content_save_pre
might work for you, i think.
Update
here is another discussionon this topic which might be helpful for you.
Related Posts:
- Check for update vs new post on save_post action
- How to avoid infinite loop in save_post callback
- $update is always true in save_post
- Action hook ‘save_post’ triggered when deleting posts
- save_post action firing before I publish / save the post
- save_post action only when creating a new post
- Check if value has changed on save_post
- Minimum Word Count Before A Post Can Be Made Pending Review
- update_post_meta() not working in save_post
- How do I save each option in a multiple select menu as it’s own meta_key + meta_value pair?
- Update post on save
- Post meta checkbox becomes unchecked occasionally
- Return code from save_post action?
- update_post_meta not working in save_post
- save_post only saves meta data on second save
- Get Post ID with insert/edit link
- How to manage saving custom field from Quick edit and Post Save using save_post action hook without colliding each other?
- Why save_post_$(custom_post_type) is fired even if I am not already saving a post?
- Set the value of custom field when post is published or updated
- pass error to admin_notices on “quick edit”/save_post action
- save_post requiere at least one uploaded file to be published
- Get $_POST & $_REQUEST values before adding/updating post
- How can I create a new user account while creating a new post, and then set that new user as the author of that new post?
- Validate post checking if child term is assigned
- Clear cache on post of one type when something happens to post of other type
- Why not fire the save_post event?
- Compare custom taxonomies of updated post (or new post) [Updated with progress]
- WordPress 4.9.8 doesn’t save if content has style=”
- Reset all transients on post or page save
- Using PODS data with save_post
- Cant’t delete my custom posts
- where does this $post_id come from?
- Update current WP post every 3 minutes [closed]
- Changing new post to “pending” on publish – but “Publish failed” – why?
- update_post_meta not working in foreach
- Save post in another table
- Strange bug on post/page save
- draft_to_pending action doesn’t seem to fire
- What action to use for when a post is saved / published, with a caveat
- Custom wp_editor doesn’t update post_content
- Save custom value to main content of post
- Check for page template on save_post hook
- Access NEW/UPDATED post values in save_post() callback function
- save button grayed out randomly
- Post editor doesn’t save embed media [closed]
- How to get a post meta value and pass that to update_option when a post is created or updated?
- WordPress save meta data : Displaying the word Array when selected
- Save current post using custom save button
- Connection Reset on post/page save
- Meta data not saved on save_post
- Insert/Update DB table when making new post or update older one
- Prevent Page/Post From Being Created based on Pages/Posts per User per Time Unit
- How to debug | Some times the “Save Draft” button seems to spin but does not actually save
- My custom title gets duplicated at every save or post update
- Use save_post to generate file on wordpress
- Detect, if post is saved manually or programmatically in save_post-hook
- Prevent post from being published if custom fields not filled
- Metabox with checkbox is not updating
- Execute action after post is saved with all related post_meta records (data)
- Unable to prevent function using save_post firing twice
- Submitting posts from the front end – sanitizing data
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- save_post + insert_post = infinite loop
- How to stop a user from updating the post date
- Why can’t I hook into save_posts after admin_init?
- How can I pass $post object to ‘save_post’ add_action?
- Returning ACF custom field from publish_post
- Post Auto Draft Issue
- Cron While Editing Post
- Custom Post Custom Taxonomy Data Not Saving in Edit Screen
- Is it possible to create a post using a metabox?
- Set default Custom Post Meta Value
- Add meta field after post has been published
- How to catch and modify custom field values when a page is updated
- save imported posts as drafts
- save_post action to include wp_insert_post_data filter, gathering meta field info & prevent infinite loop
- “The link you followed has expired” & “Error while saving” messages when adding new post
- Auto-Select Parent Category as Primary
- Check if post is added manually or through wp_insert_post()
- Get updated meta value after post update or published (custom post type) using hook
- Can’t find infinite loop cause
- custom-meta-box checkboxes from loop won’t save
- Remove a category from a post when saving a new post
- detect when a custom post is cretaed for the first time
- Why does not my metabox save?
- ‘save_post’ hook not working in WP 3.5
- Custom meta box values are not getting saved for my custom post type
- frontend submit post jQuery clone row won’t save
- Can wp_insert_post_data filter be used to save custom field data?
- remove_action(‘save_post’) in function that was triggered by save post not working
- Save post action is called twice
- Custom taxonomy only gets saved in quick edit
- Copy permalink to clipboard automatically when publish/update posts?
- Urgent – WordPress keeps creating posts
- Custom post types saved as basic post
- problem with admin panel
- How to change the post author when the post is published?
- Problem with executing a function on saving a post
- Return $post_id when DOING_AUTOSAVE?
- How to extend the page editor?