Contents
What are the different post status transitions in WordPress?
There are three kinds of post status transition action hooks: All three actions are called by wp_transition_post_status () in wp-includes/post.php . The available post statuses are: new – When there’s no previous status (this means these hooks are always run whenever “save_post” runs. publish – A published post or page.
What is the function for post status transition?
The function wp_transition_post_status () is used to call the post status transition actions and can be found in wp-includes/post.php. This function would be useful if your plugin directly modifies the database, thereby bypassing the usual post status transition action hooks.
When does the transition post status Hook fire?
Please note that the name transition_post_status is misleading. The hook does not only fire on a post status transition but also when a post is updated while the status is not changed from one to another at all.
What are the default post types in WordPress?
Default values for post type are post, page, attachment, revision, navigation. Additionally, custom post types may also be used. The publish_post and publish_page actions had been identified as deprecated on the Action Reference page and the publish_post and publish_page action pages. This was not correct.
When to use hook on post status transition?
The hook does not only fire on a post status transition but also when a post is updated while the status is not changed from one to another at all. So if you wish to really only do stuff on status transition and not on regular post updates, you will need to (at least) start with a basic bailout like this:
What happens when a post is saved to WordPress?
When a post is saved, the post status is “transitioned” from one status to another, though this does not always mean the status has actually changed before and after the save.