Fires once an existing post has been updated.
Parameters
Source
do_action( 'post_updated', $post_id, $post_after, $post_before );
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Fires once an existing post has been updated.
do_action( 'post_updated', $post_id, $post_after, $post_before );
Version | Description |
---|---|
3.0.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
This hook does not compare values of post meta keys if you have changed those as well. $post_after and $post_before will include strictly the new/old post data without meta fields of post.
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: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)