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 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
- How to allow hidden custom fields to be added from wp-admin/post.php?
- How to show list of posts by author and category?
- How to add editor’s name to entry meta byline?
- Will a large postmeta table slow a site down?
- How to display posts by current user/author in a custom page template?
- How to batch update post content with custom post meta value
- Change slug with custom field
- Search posts by post author name
- Get the user type of an author
- Show the title of the latest post by author
- Find most recent authors
- Show author post count in sidebar – Variable
- Edit meta data does’t work with custom sql
- Filter posts by author and category simultaneously
- Human Time Diff, change mins to minutes
- Have save_post write to database image meta [closed]
- Get all posts by post_author
- Exporting Data from WordPress into a flat table
- Adding Multiple Values to a Post Meta Key
- Using radio button meta data from a custom meta box
- Authors in menu, template list post by author
- PHP Notice error (when on 404 page)
- Checking if a post with certain meta value exists
- How to permanently delete a post meta entry?
- Modify WP_Post before processing
- 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?
- 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?
- How to get post bulk edit action trigger and get edited post ids?
- 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
- Force the “Choose from the most used tags” meta box section to always be expanded
- Meta value does not save for scheduled posts
- Updating post data on save (save_post vs wp_insert_post_data)
- How to compare two posts including their meta fields on a scalable base?
- Is it possible to paste a link without tags and make it directly a link in a post?
- Cannot retrieve a custom RSS field from posts
- Display Notification Bar on Header on Certain Post Count
- How do I retrieve a users’ last 5 posts?
- obtain the author id given the post id
- save_post hook is not called when post is saved
- How to calculate the average of a post meta value(Numeric) of a specific author
- static landing page leading to author specific pages w/ “live” content
- wpColorPicker – problem with implementation to post meta
- Is it possible to lock all new and existing WordPress posts to one specific author?
- Restrict displaying posts to the poster itself (in Back-end)
- Add multiple meta keys to a post at once
- Show number of posts by logged in user
- How does WP decide how to display a page
- How can I set a maximum allowed post size and number of posts submitted?
- Change Author Name to Sitename on Frontend
- Insert data from custom created PHP page into wp_postmeta table
- Exclude a category of posts in author template
- The loop starting at a certain ID
- saving/reading custom field value does not work – no value gets POSTed
- Simple Custom Metabox Not Saving
- Send email to admin with post author
- Prevent 404 of Author pages without posts
- Save / Update meta data as multidimensional array
- Select another post in a post meta like a parent page is selected while editing a page
- SQL DELETE multiple post_meta on single and multi-sites
- Restricting displayed posts to posts from only select authors
- Execute php after post save/update
- What permissions does a role need for the user to be assigned as the author of a post?
- Automatically select template based on query string for New Posts
- Add postmeta to all blog posts
- problem with admin panel
- WP_Query sort by meta_value_num or date
- How to fetch posts that are stored in the different table than the default table (wp_posts)?
- Check if user has avatar
- Creating Ordered Query using Meta_key
- Changing the Category for all posts of an Author
- List of authors posts minus very latest
- Filter question list on substring of metavalue
- Add a meta to a post submited from a frontend form
- show latest authors blog post
- How to get only current images of a post
- Run function after post is updated
- Adding custom fields to the Quick Edit screen – puzzled about the column concept
- Create a Page Template Which Displays All Posts by Current User
- Set the limit to allow author when make post!
- How to get single post by one author?
- Notify Author of the post if admin deletes his post and perform some function
- WP_query sort by custom meta_key “price”
- How can I add Author’s phone number to wp profile and make it appear in wp-admin/edit.php columns
- NewsPaper WP Theme – Additional Related Posts Filter by Time (divTag composer)
- What effect can a large wp_post table have on overall site performance?
- Site ‘Categories’: save an admin global setting with post metadata [closed]