钩子文档

post_edit_category_parent_dropdown_args

💡 云策文档标注

概述

此文档介绍 post_edit_category_parent_dropdown_args 过滤器,用于在文章编辑页面自定义分类法父级下拉菜单的参数。该过滤器允许开发者修改生成下拉菜单时使用的参数数组,以调整菜单的行为和显示。

关键要点

  • 过滤器名称:post_edit_category_parent_dropdown_args
  • 应用场景:文章编辑页面的分类法父级下拉菜单
  • 参数:$parent_dropdown_args(数组),包含如 taxonomy、hide_if_empty、name、orderby、hierarchical、show_option_none 等键值
  • 默认值:例如 name 默认为 "new{$tax_name}_parent",orderby 默认为 'name',hierarchical 默认为 1
  • 相关函数:_wp_ajax_add_hierarchical_term() 和 post_categories_meta_box()
  • 引入版本:WordPress 4.4.0

代码示例

$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );

📄 原文内容

Filters the arguments for the taxonomy parent dropdown on the Post Edit page.

Parameters

$parent_dropdown_argsarray
Array of arguments to generate parent dropdown.

  • taxonomy string
    Name of the taxonomy to retrieve.
  • hide_if_empty bool
    True to skip generating markup if no categories are found. Default 0.
  • name string
    Value for the 'name' attribute of the select element.
    Default “new{$tax_name}_parent”.
  • orderby string
    Which column to use for ordering terms. Default 'name'.
  • hierarchical bool|int
    Whether to traverse the taxonomy hierarchy. Default 1.
  • show_option_none string
    Text to display for the “none” option.
    Default “— {$parent} —”, where $parent is 'parent_item' taxonomy label.

Source

$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );

Changelog

Version Description
4.4.0 Introduced.