do_action( 'post_updated', int $post_ID , WP_Post $post_after , WP_Post $post_before )
Fires once an existing post has been updated.
Parameters
More Information
Use this hook whenever you need to compare values before and after the post update.
This hook runs after the database update.
This hook pass up to 3 arguments, as follows:
$post_ID
;$post_after
(post object after the update);$post_before
(post object before the update);
Source
File: wp-includes/post.php
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example migrated from Codex:
Suppose we have a post named Original Title and we edit it to Edited Title. Let’s hook to post_updated to check what has changed:
Let’s hook to
post_updated
to check what has changed:Expand full source codeCollapse full source code
The Result then would be this:
Post ID:
int 1403
Post Object AFTER update:
object(WP_Post)[7722]
public 'ID' => int 1403
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2014-08-10 18:19:43' (length=19)
public 'post_date_gmt' => string '2014-08-10 18:19:43' (length=19)
public 'post_content' => string (length=0)
public 'post_title' => string 'Edited Title' (length=12)
public 'post_excerpt' => string (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string (length=0)
public 'post_name' => string 'edited-title' (length=12)
public 'to_ping' => string (length=0)
public 'pinged' => string (length=0)
public 'post_modified' => string '2014-08-10 19:41:46' (length=19)
public 'post_modified_gmt' => string '2014-08-10 19:41:46' (length=19)
public 'post_content_filtered' => string (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://localhost:8888/mysite/?post_type=test_post&p=1403' (length=67)
public 'menu_order' => int 0
public 'post_type' => string 'procedimentos' (length=13)
public 'post_mime_type' => string (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
Post Object BEFORE update:
object(WP_Post)[7724]
public 'ID' => int 1403
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2014-08-10 18:19:43' (length=19)
public 'post_date_gmt' => string '2014-08-10 18:19:43' (length=19)
public 'post_content' => string (length=0)
public 'post_title' => string 'Original Title' (length=14)
public 'post_excerpt' => string (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string (length=0)
public 'post_name' => string 'original-title' (length=14)
public 'to_ping' => string (length=0)
public 'pinged' => string (length=0)
public 'post_modified' => string '2014-08-10 19:41:14' (length=19)
public 'post_modified_gmt' => string '2014-08-10 19:41:14' (length=19)
public 'post_content_filtered' => string (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://localhost:8888/mysite/?post_type=test_post&p=1403' (length=67)
public 'menu_order' => int 0
public 'post_type' => string 'procedimentos' (length=13)
public 'post_mime_type' => string (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)