It’s wp_insert_post()
vs.
wp_update_post()
– where update will ultimately also call:
return wp_insert_post( $postarr, $wp_error, $fire_after_hooks );
The term “once” implies that it is being fired “afterwards”.
/**
* Fires once a post has been saved.
*
* @since 1.5.0
*
* @param int $post_ID Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
*/
do_action( 'save_post', $post_ID, $post, $update );
When inserting a post, save_post
is being fired while $fire_after_hooks
is true
.
And usually one may want to insert/update the record and not only fire the hook …
Related Posts:
- Event-Driven Pattern vs MVC?
- Change status of page after an event (Looking for best practice advice)
- profile_update hook does not fire from front-end
- WordPress save_post hook not firing when checking if _GET[‘post’] is set
- How do I set a custom post type Category after import using wp_set_post_terms
- How to know what functions are hooked to an action/filter?
- what is correct way to hook when update post
- Please explain how these hooks work
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- How to remove action hook done in a plugin from functions.php in my theme?
- Implementing advanced add_* function wrappers
- My add_action (wp_footer, ‘method’) is not calling?
- What is the earliest possible hook for safely using `is_front_page`?
- Send data to 3rd party api with wp_remote_post on wp_login
- is it possible to get the hook name in add_action?
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- Difference between hooks Plugin_loaded and admin_int?
- Wp_update_post: Infinite loop even with remove_action solution, OOP
- admin_post hook not called
- How to debug removal of rewrite rule flushing?
- Detect type of post status transition
- Hook before inserting user into database [duplicate]
- How to pass arguments to add_action() [duplicate]
- How to use the post_updated hook before and after arguments
- WP Admin Bar frontend issue with dashicon deregister
- How can i trigger an action manually?
- wp_redirect() not working on form submission with init hook
- add_action for lost_password or modify wp-login.php?action=lostpassword
- How to check what kind of saving it is?
- Add my own function to existing WooCommerce hook
- Empty Super Cache programmatically (with ACF action) [closed]
- What is the best filter where to use register_block_type?
- Admin Hook at the Login Page
- How To Make Sure That My Action Hook Executes Last
- Does update_comment_meta hook exists?
- how to determine how many and what kind of arguments are passed to hooks
- WP CLI Get all Enqueued Scripts and Styles
- Delay an action until current action is completed
- What’s hook to use immediately after a user is authentcated [duplicate]
- Looking for a hook for post.php
- Update a costume wp_usermeta key back to 0 every 24hours (time can be specified as needed)
- Save User Meta Email Address in Lowercase
- Save acf field data via acf/save_post before post is saved
- Execute JavaScript in WordPress Hook
- schedule event in class oriented plugin
- Hooks are not being removed in child theme
- Removing parent theme action on pluggable function not working
- Which action hook should I use to intercept a form upon submission?
- How do I prevent term from being created on create_term hook?
- Would there be anything stopping me from removing both wp_head and wp_footer?
- Is it possible to add the_content filter upon login?
- WordPress wp_loaded action hook
- add_action second argument missing
- Bug: Post needs to be updated twice when adding action for save_post hook
- admin_notices action doesn’t trigger within save_post action
- I don’t understand how add_action and do_action work in tandem. The former executes the code already…what is do_action for?
- Check if `do_action()` in WordPress returns any result
- save_post hook to add terms getting deleted when using bulk edit
- How to cancel an action hooked to untrash_post? or any hook
- Add Different Actions To Different Page’s wp_footer
- add_action hook for publish_post not working
- Hook for inserting?
- dynamic add_action according to child pages (for homepage control)
- Remove action in a parent theme from the child theme
- Remove action within a class in a parent theme’s includes folder from the child theme
- Remove genesis_404 hook from genesis_loop [closed]
- Add html code in admin page
- What hook to add at start of WordPress load
- A good hook to check authorization and redirect?
- Adding custom Bulk Actions
- Is there a author_update action?
- Restrict editing of post type to list stored in user meta
- How to stop execution of a function via add_action hook?
- Can we change the hook firing sequence?
- changing genesis_before_while in new theme framework
- Rewrite the search page to use an appended slug + parameter
- How to call do_action() to pass arguments to hooked functions that take different number of args?
- Is there a way to know when a page has been updated and do some action only once?
- remove_action not working for a function
- do_action not working in loop
- add_action doesn’t work for my function
- Add HTML code before the title of the Tag page
- Check if front page within function passed to action
- Hooks with same priority number. Can one stack items returned in divs, position: absolute each with their own z-index?
- Can add_image_size be added earlier
- $new_pass always returns null – password_reset hook
- Why does get_post() not return anything?
- Hourly events don’t get triggered
- set_post_format called after wp_update_post when using bulk edit?
- Object oriented programming, add_action in constructor not firing
- add hook restricted only to either plugins or themes?
- Using actions, hooks and filters in a non-WordPress page
- addaction hook cause redirection problem
- Removing action from template class
- Which hook should I use for this scenario regarding the registration process and account/profile update?
- Redirect back to origin page after using get_delete_post_link()
- How do I override the user’s input when updating a custom post type’s permalink?
- How to add a new link to the default register form’s footer links?
- admin_post hook not working
- Hooks to trigger a callback when adding, removing, rearranging or updating a widget in the widget area