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

---

# apply_filters( ‘wp_insert_post_parent’, int $post_parent, int $post_id, array $new_postarr, array $postarr )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_insert_post_parent/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_insert_post_parent/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_insert_post_parent/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_insert_post_parent/?output_format=md#changelog)

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

Filters the post parent — used to check for and prevent hierarchy loops.

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

 `$post_parent`int

Post parent ID.

`$post_id`int

Post ID.

`$new_postarr`array

Array of parsed post data.

`$postarr`array

Array of sanitized, but otherwise unmodified post data.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_insert_post_parent/?output_format=md#source)󠁿

    ```php
    $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
    ```

[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#L4776)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/post.php#L4776-L4776)

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

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

## User Contributed Notes

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