page_attributes_dropdown_pages_args
云策文档标注
概述
page_attributes_dropdown_pages_args 是一个 WordPress 过滤器钩子,用于修改生成页面下拉列表元素时使用的参数。它主要应用于页面属性元框中的下拉选择功能。
关键要点
- 过滤器钩子名称:page_attributes_dropdown_pages_args
- 用途:过滤生成页面下拉列表的参数,允许开发者自定义下拉列表的行为和显示内容
- 参数:$dropdown_args(参数数组)和 $post(当前文章对象)
- 相关函数:与 wp_dropdown_pages() 函数关联,用于页面属性元框的显示
- 注意事项:在 Gutenberg/Block Editor 中可能不工作,需要使用替代方法如 rest_{$this->post_type}_query 过滤器
注意事项
- 此钩子在经典编辑器中有效,但在 Gutenberg/Block Editor 中可能无法正常工作,因为后者基于 JavaScript 渲染。
- 对于 Gutenberg/Block Editor,建议使用 rest_{$this->post_type}_query 过滤器来覆盖查询参数。
- 相关问题和解决方案可参考 GitHub 和 WordPress Stack Exchange 上的讨论。
原文内容
Filters the arguments used to generate a Pages drop-down element.
Description
See also
Parameters
$dropdown_argsarray-
Array of arguments used to generate the pages drop-down.
$postWP_Post-
The current post.
Source
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |
Skip to note 2 content
gpius
This hook is not working with Gutenberg / Block Editor
“The following conditions is assumed to make it working:
Classic Editor is in use, since Gutenberg/Block Editor is rendered by Javascript, it requires another solutions and so far I am not sure if there is override option yet.”
Override method for Gutenberg/Block Editor
Please use the filter rest_{$this->post_type}_query to override the query
Open Issue: https://github.com/WordPress/gutenberg/issues/9089
Source:
https://wordpress.stackexchange.com/a/365451