wp_insert_post_parent
Filters the post parent -- used to check for and prevent hierarchy loops.
Usage
add_filter( 'wp_insert_post_parent', 'wp_kama_insert_post_parent_filter', 10, 4 ); /** * Function for `wp_insert_post_parent` filter-hook. * * @param int $post_parent Post parent ID. * @param int $post_id Post ID. * @param array $new_postarr Array of parsed post data. * @param array $postarr Array of sanitized, but otherwise unmodified post data. * * @return int */ function wp_kama_insert_post_parent_filter( $post_parent, $post_id, $new_postarr, $postarr ){ // filter... return $post_parent; }
- $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.
Changelog
Since 3.1.0 | Introduced. |
Where the hook is called
wp_insert_post_parent
wp-includes/post.php 4483
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
Where the hook is used in WordPress
wp-includes/default-filters.php 184
add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );