post_categories_meta_box

函数


post_categories_meta_box ( $post, $box )
参数
  • (WP_Post)
    $post
    Current post object.
    Required:
  • (array)
    $box
    { Categories meta box arguments. @type string $id Meta box ‘id’ attribute. @type string $title Meta box title. @type callable $callback Meta box display callback. @type array $args { Extra meta box arguments. @type string $taxonomy Taxonomy. Default ‘category’. } }
    Required:
定义位置
  • wp-admin/includes/meta-boxes.php
    , line 591
引入
2.6.0
弃用

Displays post categories form fields.

function post_categories_meta_box( $post, $box ) {
	$defaults = array( 'taxonomy' => 'category' );
	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
		$args = array();
	} else {
		$args = $box['args'];
	}
	$parsed_args = wp_parse_args( $args, $defaults );
	$tax_name    = esc_attr( $parsed_args['taxonomy'] );
	$taxonomy    = get_taxonomy( $parsed_args['taxonomy'] );
	?>
	
  • labels->all_items; ?>
  • labels->most_used ); ?>
"; ?>
    ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids, ) ); ?>
cap->edit_terms ) ) : ?>
labels->add_new_item ); ?>

$tax_name, 'hide_empty' => 0, 'name' => 'new' . $tax_name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', ); /** * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. * * @since 4.4.0 * * @param array $parent_dropdown_args { * Optional. Array of arguments to generate parent dropdown. * * @type string $taxonomy Name of the taxonomy to retrieve. * @type bool $hide_if_empty True to skip generating markup if no * categories are found. Default 0. * @type string $name Value for the 'name' attribute * of the select element. * Default "new{$tax_name}_parent". * @type string $orderby Which column to use for ordering * terms. Default 'name'. * @type bool|int $hierarchical Whether to traverse the taxonomy * hierarchy. Default 1. * @type string $show_option_none Text to display for the "none" option. * Default "— {$parent} —", * where `$parent` is 'parent_item' * taxonomy label. * } */ $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); wp_dropdown_categories( $parent_dropdown_args ); ?>