Title: post_updated
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_action( ‘post_updated’, int $post_id, WP_Post $post_after, WP_Post $post_before )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#wp--skip-link--target)

Fires once an existing post has been updated.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#parameters)󠁿

 `$post_id`int

Post ID.

`$post_after`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)

Post object following the update.

`$post_before`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)

Post object before the update.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#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](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#source)󠁿

    ```php
    do_action( 'post_updated', $post_id, $post_after, $post_before );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/post.php#L5163)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/post.php#L5163-L5163)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_insert_post()](https://developer.wordpress.org/reference/functions/wp_insert_post/)`wp-includes/post.php` |

Inserts or update a post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#comment-content-6162)
 2.    [Tunn](https://profiles.wordpress.org/iuriem/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/post_updated/#comment-6162)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%23comment-6162)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%23comment-6162)
 4.  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.
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%3Freplytocom%3D6162%23feedback-editor-6162)
 6.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/post_updated/?output_format=md#comment-content-4179)
 7.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/post_updated/#comment-4179)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%23comment-4179)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%23comment-4179)
 9.  Example migrated from Codex:
 10. 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:
 11. Let’s hook to `post_updated` to check what has changed:
 12.     ```php
         <?php
         function check_values($post_ID, $post_after, $post_before){
             echo '<b>Post ID:</b><br />';
             var_dump($post_ID);
     
             echo '<b>Post Object AFTER update:</b><br />';
             var_dump($post_after);
     
             echo '<b>Post Object BEFORE update:</b><br />';
             var_dump($post_before);
         }
     
         add_action( 'post_updated', 'check_values', 10, 3 ); //don't forget the last argument to allow all three arguments of the function
         ?>
         ```
     
 13. 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)
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F%3Freplytocom%3D4179%23feedback-editor-4179)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_updated%2F)
before being able to contribute a note or feedback.