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?
- Implementing Soft Delete for Bulk Actions / Empty Trash
- How to automatically generate a unique random slug
- How does filter the_posts work?
- Querying post from a multisite network
- Publish pending article from front end with a button?
- Invalid Post Type error when attempting to filter and Bulk Edit posts
- How can I export WordPress posts’ attachments?
- Only display posts with comments
- How to update all post at once?
- Force update all posts in custom post type, no content changes
- Add custom field to category of custom post type
- Change post format using custom field
- How to Customize number of blog posts on first page?
- Load posts into sidebar and paginate via ajax?
- How to intercept Post Title on Post-Save
- Display Latest Post from all Categories
- Sort posts by newest child while keeping hierarchy intact
- Custom Theme Want To Remove One Category From All Displays
- Instead of submiting an entire post, is there any way to submit a lite-post or a simple message?
- How do I use Ajax to show the new posts realtime, on the frontpage
- Allow anonymous users to post to my site for moderation
- How Can i Get 5 Recent Post Title With Corresponding Link?
- WP_Query posts_per_page ignored
- Easy way to delete 70k posts and attached media?
- wp_insert_post works, but the post isn’t visible in the admin post list or front end
- XML-RPC and post_date
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- Define a wordpress constant through plugin functions?
- Show all posts in sidebar in single.php
- How to display data in archive page?
- recent posts for different categories
- Drag posts and pages so you can sort them in order
- import mailchimp newsletters into wordpress [closed]
- CPT archive redirects to single post
- Archiving by academic year instead of calendar year
- Display News Posts by Day with Post Counter
- Overwrite posts/pages via import
- Auto-realod with new posts // Ajax call
- Is it possible to add/tick a category to a post when it is created?
- How many posts does the loop return?
- Posts loop displaying the same post data
- Display Posts on Custom Page
- Blog Post On Home Page Displaying Page Published Date Not Post Published Date
- The_excerpt() doesn’t parse – how to change that?
- Can’t understand why sometimes a [caption] field appears
- Trying to edit archive.php to only show post extract, with featured image
- Divs appearing everywhere in post content
- Latest posts by category β how to exclude current post?
- Posts page not showing correct image
- Sticky Post from page 2 and on
- Edit custom fields in posts list
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Restore woocommerce orders
- Can WordPress handle following functionalities?
- query for filtering published posts?
- All images on one line for each post
- Pull in posts using post meta for REST API
- how to show comments only author which send own posts in wordpress
- Please help a newbie with blog page issue?
- Alt text attributes not showing over portfolio images
- How to sort WP_Post Object array by object field in php?
- WordPress Recent Post with the badge βNewβ on the side of the title post
- Unable to delete attached file from folder programmatically
- How to create page with post content in it?
- Top tags with minimum number of posts
- Administrator Posts
- On WordPress Search, how to search post from Author meta also
- Single Sidebar; multiple templates! How?
- is there a way to get the ‘read more’ tag in a manual excerpt
- Next / Previous post in a single category
- How can I view my posts in ascending order by number of views
- Override wp_link_pages pagebreak with filter
- How to sort posts in admin by name
- Extracting a TLD from the content and assign to custom field
- get_page_by_title() not working if special characters are present
- Hide categories from showing above a Post
- how to create a new page that is not in the hierarchy?
- How to custom sort-out editing-panel fields?
- Related post by category throws internal server error
- Posts not showing up on Blog page
- Display posts in row Horizontally [closed]
- How to var dump urls for all posts