wp_insert_post_parent
云策文档标注
概述
wp_insert_post_parent 是一个 WordPress 过滤器钩子,用于检查和防止文章层级循环。它允许开发者在插入或更新文章时修改父文章 ID。
关键要点
- 过滤器钩子名称为 wp_insert_post_parent,用于过滤文章的父 ID。
- 主要目的是检查和防止文章层级中的循环引用,确保文章结构正确。
- 参数包括 $post_parent(父文章 ID)、$post_id(当前文章 ID)、$new_postarr(解析后的文章数据数组)和 $postarr(原始文章数据数组)。
- 在 wp_insert_post() 函数中使用,版本 3.1.0 引入。
原文内容
Filters the post parent — used to check for and prevent hierarchy loops.
Parameters
$post_parentint-
Post parent ID.
$post_idint-
Post ID.
$new_postarrarray-
Array of parsed post data.
$postarrarray-
Array of sanitized, but otherwise unmodified post data.
Source
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |