check: https://codex.wordpress.org/Function_Reference/wp_update_post
Make sure not to create an infinite loop.
<?php
function my_function( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'my_function');
// update the post, which calls save_post again
wp_update_post( $my_args );
// re-hook this function
add_action('save_post', 'my_function');
}
}
add_action('save_post', 'my_function');
?>
to stop revisions try to add: https://wordpress.stackexchange.com/a/3398
remove_action('pre_post_update', 'wp_save_post_revision');// stop revisions
and
add_action('pre_post_update', 'wp_save_post_revision');// enable revisions again
Good luck 😉
Related Posts:
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- Post/Page Publish/Update button not clickable once I make an edit
- How to batch update post content with custom post meta value
- Updating a post without escaping ampersands?
- Update post date on every new comment?
- Mass Update lines of code for all posts
- Unable to modify(update) posts – Page not found
- How do I batch create revisions of all posts?
- custom post scheduler for drafts
- If modified on same day, show only time
- Can’t update WordPress Page if post_content is Empty
- Bulk update published posts date randomly using wp-cli?
- Run a function when a custom post is update?
- wp_trash_post() duplicates post to trash
- Set a post expiration and delete a post when expirate
- Bulk Post update_post_meta
- Update Post with Modified Data
- How can I use wp_after_insert_post with $current_screen?
- Should we trust the post globals?
- how to limit edit_form_after_title hook to page and post edit only?
- Add a checkbox to post screen that adds a class to the title
- count number of posts (public , private , protected) by category name
- How to call function within a page/post, to dynamically generate content?
- Remove image caption from post excerpt
- How to force update all posts after import
- How to have different content in the loop and single
- Make “Post published. View post” Open in a New Tab
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- New posts defaulting to ‘0’ primary key
- add image map script to post
- How to create shortcode to show the 2 latest posts
- Multiple authors for single post without plugin
- Same content shared between multiple posts?
- How to add in title a date but with other color, like in iMDb titles?
- Remove custom posts that match taxonomy value
- WordPress – Admin Manage Posts – Multiple Filters by Parent Category
- Author must complete profile info before they can publish a post?
- Check if post exists
- Disable author profile in post
- How to set up multiple taxonomies for groups of posts
- Update admin side post list count text
- How can I set a Post’s default visibility to private and pending review checked
- Blog Posts in Custom Menu
- Receive each week the number of posts published
- Transfer WordPress post to RoR site: is the REST Api the only and/or best solution?
- Alternate row and columns every X posts
- How do I get blog posts to appear within CMS?
- Multisite: Can’t Post or Create Categories
- Query values from a Post Object Repeater [closed]
- Post visibility based on user role
- how to bulk add one line in the first paragraph of all posts
- Multiple Loops Breaking Pages
- Why are my paginated posts always returning the same results?
- Admin – no Featured image choice in create new/page|post
- Hook for changing excerpt content when excerpt not set
- How to exclude posts that already appear in the main loop, from the category loop
- How come a YouTube link isn’t transformed into a shortcode inside the post content?
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- How do I limit the number of posts displayed to one?
- wordpress add field to post_class
- write a post on user registration
- Cannot select certain authors for posts after import
- Lightbox on wordpress post page
- WordPress Architecture as a CMS – Posts & Pages
- Getting post and attached image from subdomain
- How to list post as buch of category, and all of them
- Is it to possible to insert a page in the post depending on the category ofthe post
- How to display a “NEW”-icon on posts from today
- How to get post id of last approved comment?
- Trim posts from WP-Query?
- Not adding a new post?
- Prevent the automatic URL linking added in last update
- Thumbnails and images in the blog post are not loading
- Automatically delete post in a single category when a new one is created
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- Multiple posts in one page
- post__in no longer works in wordpress 5.0.3
- How to count posts in tags within time limit
- What’s the best approach to create duplicated pages with paginated posts?
- How to allow some visitors to edit inline specific post
- alt of attached image in post / pages
- Posts are printed twice
- How to display most popular posts from certain category in sidebar?
- Is possible to do this from function.php
- Hook To Get All Posts Deleted
- Make Show Notes for Individual Podcast Episodes Easy to Find (multiple URL’s?)
- Users cannot post when editor or admin on more than 1 site on multisite
- Creating / Editing a post from within site template
- display only the title of the post into a certain category
- WordPress “Posts Page” isn’t showing template dropdown
- Post only showing on homepage when Logged in – direct URL still working
- How can I get on the same row two post of different categories?
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- Trying to create parent for post. I need some help. Thanks
- The WordPress wp_posts data table
- How to automatically convert a form with HTML link into post
- how to change background color of my all post
- WordPress Post Updating is Not Working
- How to use shortcode to get the second to newest post?
- WordPress + Polylang – Error 404 when trying to preview draft post on different language