0

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: list view

Grid 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 );
  • Can you show the code for the Artwork checkbox? – Himad Mar 6 at 11:42
  • The artwork checkbox has been added with Advanced Custom Fields, there's no actual code for it. I have checked the view with my custom theme and ACF disabled (and the color taxonomy added through a plugin), but the result is the same. – Dominique Pijnenburg Mar 6 at 12:43
0

Setting 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;
        }
| improve this answer | |
  • After changing the 'public' value to true, the taxonomy pops up in the modal, but it shows up as a text field. – Dominique Pijnenburg Mar 6 at 13:19
  • Apparently this is due to a bug that's in WordPress since version 3.5. I ended up using a taxonomy field from Advanced Custom Fields. I've hidden the taxonomy input in the grid library and hidden the ACF field in the list view. – Dominique Pijnenburg Mar 6 at 17:26
  • Here's a link to the thread, by the way. – Dominique Pijnenburg Mar 9 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.