On the few occasions when I’ve needed to do something similar, I’ve used the callback unattach-update-reattach method, which is also described on this older Q&A, Update post on save and on the developer docs comments.
function your_save_post_callback( $post_id, $post, $update ) {
// unattach the callback
remove_action('save_post', 'your_save_post_callback');
// update post
wp_update_post( $args );
// reattach the callback
add_action('save_post', 'your_save_post_callback');
}
Related Posts:
- Better post meta efficiency?
- Get Meta Key Value While Saving Post
- Change all author links in Blog roll
- Update post meta within save_post action
- How to hide meta from search result only on pages?
- How to check if post meta key exists or not in wordpress database
- How to add category to: ‘wp-admin/post-new.php’?
- Hook that get’s triggered when the author of a post is changed
- the_author() returns empty string
- Prevent Authors from viewing each others Posts
- How can I retrieve multiple get_post_meta values efficiently?
- Code to make a post sticky
- Display Random Author with Details in Sidebar
- How to allow hidden custom fields to be added from wp-admin/post.php?
- Export WordPress Posts and Meta Information in CSV format
- How to show list of posts by author and category?
- WordPress: How to get the current logged in author page URL?
- Delete duplicated wp_postmeta record
- How to add editor’s name to entry meta byline?
- Different permalink for posts and authors
- Will a large postmeta table slow a site down?
- Update all posts automatically when using post_meta
- What to use: wp_is_post_autosave( $post_id ) or DOING_AUTOSAVE?
- How to display posts by current user/author in a custom page template?
- How to batch update post content with custom post meta value
- Query posts distinct authors
- Change slug with custom field
- Restrict the Number of Posts an Author can Publish (over time)?
- Search posts by post author name
- Get the user type of an author
- Show the title of the latest post by author
- Setting post meta data to random value during post status transition / on publish
- Find most recent authors
- Show author post count in sidebar – Variable
- How can I pass $post object to ‘save_post’ add_action?
- Edit meta data does’t work with custom sql
- Get current users post URL?
- Get the author of the latest revision
- Filter posts by author and category simultaneously
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Human Time Diff, change mins to minutes
- Post author is changed to admin after his post is modified by admin
- Change post format using custom field
- Have save_post write to database image meta [closed]
- Get the post_id of a new post
- Get all posts by post_author
- Does WP get all post_meta on POST page?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Exporting Data from WordPress into a flat table
- Adding Multiple Values to a Post Meta Key
- How can I control multiple editing of wordpress posts?
- Using radio button meta data from a custom meta box
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- Authors in menu, template list post by author
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- WP rest api returns 404 only when author param is used
- publish_post conflicts with save_post
- How can I list random authors from current post category?
- PHP Notice error (when on 404 page)
- What Is meta_id In wp_postmeta?
- Checking if a post with certain meta value exists
- How to permanently delete a post meta entry?
- Add custom field automatically (add_post_meta) with value based on number of words of article
- How to generate numbers indistinguishable for the IDs of the posts
- Modify WP_Post before processing
- Save re-arranged draggable post items to wordpress database
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Change post_date to post_modified date on post template?
- How can I show wordpress posts based on author?
- Show info to author only
- Auto “expire” all of an authors posts on spcific date
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- How to get the user meta data for a post?
- Limit posts per author role (excluding admin) in home page
- Guest Author – How to display posts on /author/ archive page
- How to get post bulk edit action trigger and get edited post ids?
- How can I show many posts an author has per week?
- How to give capability (publish contributors posts) to author role?
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- Whitelist Author of Private Post
- Show posts by a custom post author
- Force the “Choose from the most used tags” meta box section to always be expanded
- Meta value does not save for scheduled posts
- Custom Posts Query and meta_query Sort Order
- Updating post data on save (save_post vs wp_insert_post_data)
- Getting the current author (it has changed) of a post, not the original author
- How to compare two posts including their meta fields on a scalable base?
- Getting value from get_post_custom
- Calling Different Custom Post Timestamps in a table
- Is it possible to paste a link without tags and make it directly a link in a post?
- Showing author page if user has no post
- Cannot retrieve a custom RSS field from posts
- Saving custom fields to a custom taxonomy
- Display Notification Bar on Header on Certain Post Count
- How to automate featured posts number? [duplicate]
- How do I retrieve a users’ last 5 posts?