I've added a taxonomy called 'colors' to the built-in attachment post type. I can see the taxonomy when editing an item the 'list' view, but when using the 'grid' view, I can't see/use the terms of the taxonomy.
List view:
Grid view:
I want the taxonomy to show up in the grid view as well, but can't figure out why it's not doing that.
This is my code for registering the custom taxonomy:
function nij_register_taxonomies() {
$taxonomy_names = array(
'singular' => __( 'Color', 'stufig' ),
'plural' => __( 'Colors', 'stufig' )
);
register_taxonomy( strtolower($taxonomy_names['singular']),
array('attachment'),
array(
'labels' => array(
'name' => sprintf( _x( '%s', 'taxonomy general name', 'stufig' ), $taxonomy_names['plural'] ),
'singular_name' => sprintf( _x( '%s', 'taxonomy singular name', 'stufig' ), $taxonomy_names['singular'] ),
'search_items' => sprintf( __( 'Search %s', 'stufig' ), $taxonomy_names['plural'] ),
'all_items' => sprintf( __( 'All %s', 'stufig' ), $taxonomy_names['plural'] ),
'parent_item' => sprintf( __( 'Parent %s', 'stufig' ), $taxonomy_names['singular'] ),
'parent_item_colon' => sprintf( __( 'Parent %s:', 'stufig' ), $taxonomy_names['singular'] ),
'edit_item' => sprintf( __( 'Edit %s', 'stufig' ), $taxonomy_names['singular'] ),
'update_item' => sprintf( __( 'Update %s', 'stufig' ), $taxonomy_names['singular'] ),
'add_new_item' => sprintf( __( 'Add New %s', 'stufig' ), $taxonomy_names['singular'] ),
'new_item_name' => sprintf( __( 'New %s Name', 'stufig' ), $taxonomy_names['singular'] ),
'menu_name' => sprintf( __( '%s', 'stufig' ), $taxonomy_names['plural'] )
),
'public' => false,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'update_count_callback' => '_update_generic_term_count',
// 'rewrite' => array(),
)
);
}
add_action( 'init', 'nij_register_taxonomies', 11 );
I've added a taxonomy called 'colors' to the built-in attachment post type. I can see the taxonomy when editing an item the 'list' view, but when using the 'grid' view, I can't see/use the terms of the taxonomy.
List view:
Grid view:
I want the taxonomy to show up in the grid view as well, but can't figure out why it's not doing that.
This is my code for registering the custom taxonomy:
function nij_register_taxonomies() {
$taxonomy_names = array(
'singular' => __( 'Color', 'stufig' ),
'plural' => __( 'Colors', 'stufig' )
);
register_taxonomy( strtolower($taxonomy_names['singular']),
array('attachment'),
array(
'labels' => array(
'name' => sprintf( _x( '%s', 'taxonomy general name', 'stufig' ), $taxonomy_names['plural'] ),
'singular_name' => sprintf( _x( '%s', 'taxonomy singular name', 'stufig' ), $taxonomy_names['singular'] ),
'search_items' => sprintf( __( 'Search %s', 'stufig' ), $taxonomy_names['plural'] ),
'all_items' => sprintf( __( 'All %s', 'stufig' ), $taxonomy_names['plural'] ),
'parent_item' => sprintf( __( 'Parent %s', 'stufig' ), $taxonomy_names['singular'] ),
'parent_item_colon' => sprintf( __( 'Parent %s:', 'stufig' ), $taxonomy_names['singular'] ),
'edit_item' => sprintf( __( 'Edit %s', 'stufig' ), $taxonomy_names['singular'] ),
'update_item' => sprintf( __( 'Update %s', 'stufig' ), $taxonomy_names['singular'] ),
'add_new_item' => sprintf( __( 'Add New %s', 'stufig' ), $taxonomy_names['singular'] ),
'new_item_name' => sprintf( __( 'New %s Name', 'stufig' ), $taxonomy_names['singular'] ),
'menu_name' => sprintf( __( '%s', 'stufig' ), $taxonomy_names['plural'] )
),
'public' => false,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'update_count_callback' => '_update_generic_term_count',
// 'rewrite' => array(),
)
);
}
add_action( 'init', 'nij_register_taxonomies', 11 );
Share
Improve this question
asked Mar 6, 2020 at 11:22
Dominique PijnenburgDominique Pijnenburg
112 bronze badges
2
|
1 Answer
Reset to default 0Setting the argument public
to true
will do. Check out the file wp-admin/includes/media.php
, function get_compat_media_markup()
for reference:
if ( $args['in_modal'] ) {
foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
$t = (array) get_taxonomy( $taxonomy );
if ( ! $t['public'] || ! $t['show_ui'] ) {
continue;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744691815a4588255.html
Artwork
checkbox? – Himad Commented Mar 6, 2020 at 11:42