Make WordPress Core

Opened 2 years ago

Last modified 9 months ago

#54819 new defect (bug)

Adding Taxonomy with word "media" not showing list in Edit/Create Post

Reported by: auriel2017's profile auriel2017 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Wordpress Version 5.8.3
PHP version 7.4.27 (Supports 64bit values)

<?php
add_action( 'init', 'your_prefix_register_taxonomy' );
function your_prefix_register_taxonomy() {
	$labels = [
		'name'                       => esc_html__( 'Media Classes', 'your-textdomain' ),
		'singular_name'              => esc_html__( 'Media Class', 'your-textdomain' ),
		'menu_name'                  => esc_html__( 'Media Classes', 'your-textdomain' ),
		'search_items'               => esc_html__( 'Search Media Classes', 'your-textdomain' ),
		'popular_items'              => esc_html__( 'Popular Media Classes', 'your-textdomain' ),
		'all_items'                  => esc_html__( 'All Media Classes', 'your-textdomain' ),
		'parent_item'                => esc_html__( 'Parent Media Class', 'your-textdomain' ),
		'parent_item_colon'          => esc_html__( 'Parent Media Class', 'your-textdomain' ),
		'edit_item'                  => esc_html__( 'Edit Media Class', 'your-textdomain' ),
		'view_item'                  => esc_html__( 'View Media Class', 'your-textdomain' ),
		'update_item'                => esc_html__( 'Update Media Class', 'your-textdomain' ),
		'add_new_item'               => esc_html__( 'Add new media class', 'your-textdomain' ),
		'new_item_name'              => esc_html__( 'New media class name', 'your-textdomain' ),
		'separate_items_with_commas' => esc_html__( 'Separate media classes with commas', 'your-textdomain' ),
		'add_or_remove_items'        => esc_html__( 'Add or remove media classes', 'your-textdomain' ),
		'choose_from_most_used'      => esc_html__( 'Choose most used media classes', 'your-textdomain' ),
		'not_found'                  => esc_html__( 'No media classes found', 'your-textdomain' ),
		'no_terms'                   => esc_html__( 'No Media Classes', 'your-textdomain' ),
		'filter_by_item'             => esc_html__( 'Filter by media class', 'your-textdomain' ),
		'items_list_navigation'      => esc_html__( 'Media classes list pagination', 'your-textdomain' ),
		'items_list'                 => esc_html__( 'Media Classes list', 'your-textdomain' ),
		'most_used'                  => esc_html__( 'Most Used', 'your-textdomain' ),
		'back_to_items'              => esc_html__( 'Back to media classes', 'your-textdomain' ),
	];
	$args = [
		'label'              => esc_html__( 'Media Classes', 'your-textdomain' ),
		'labels'             => $labels,
		'description'        => '',
		'public'             => true,
		'publicly_queryable' => true,
		'hierarchical'       => true,
		'show_ui'            => true,
		'show_in_menu'       => true,
		'show_in_nav_menus'  => true,
		'show_in_rest'       => true,
		'show_tagcloud'      => true,
		'show_in_quick_edit' => true,
		'show_admin_column'  => true,
		'query_var'          => true,
		'sort'               => true,
		'meta_box_cb'        => 'post_tags_meta_box',
		'rest_base'          => '',
		'rewrite'            => [
			'with_front'   => true,
			'hierarchical' => true,
		],
	];
	register_taxonomy( 'media-class', ['post', 'comunidad'], $args );
}

Attachments (2)

edit-create-post.png (88.9 KB) - added by auriel2017 2 years ago.
Edit/Create Post. Not showing list of Media Class (Custom Taxonomy)
media-classes-list.png (74.9 KB) - added by auriel2017 2 years ago.
Media Class (Custom Taxonomy) has list.

Download all attachments as: .zip

Change History (4)

@auriel2017
2 years ago

Edit/Create Post. Not showing list of Media Class (Custom Taxonomy)

@auriel2017
2 years ago

Media Class (Custom Taxonomy) has list.

#1 @sabernhardt
10 months ago

  • Component changed from General to Taxonomy

#2 @nwjames
9 months ago

I added the code supplied into WP 6.1.1 as a mu-plugin and added the terms ca and cb.

The terms ca and cb were displayed as the user expected.

I had thought that the meta call callback of post_tags_meta_box may be confusing things (since it is a hierarchical taxonomy). Setting it to post_categories_meta_box or removing the callback made no difference.

I then defined the taxonomy to apply to a post type that uses the classic editor. It outputs the post_tags_meta_box as defined. This does not display the potential values. Setting it to post_categories_meta_box or removing the callback outputs the values as expected.

For me, no error found with WP 6.1.

Note: See TracTickets for help on using tickets.