• I have created a custom post type for vehicle listings and an associated taxonomy for manufacturers (code for both below).

    Im finding that I’m not able to edit the taxonomies via the bulk edit option on the edit.php view. Selecting the posts via the check boxes and then selecting Edit from the bulk actions drop down, I would expect to see the taxonomies that have been added to the selected posts and be able to remove them.

    In this screenshot you can see the cars as posts in the custom post type. Along with the column showing the manufacturer, which is the custom taxonomy associated with the post
    Ive selected the posts and selected edit via the bulk actions drop down. The Manufacturers aren’t displayed as they would normally be on a standard post.

    This is the custom post type code

    $labels = array(
    'name' => _x( 'Vehicles', 'Post type general name', 'cultivate_base_theme' ),
    'singular_name' => _x( 'Vehicle', 'Post type singular name', 'cultivate_base_theme' ),
    'menu_name' => _x( 'Vehicles', 'Admin Menu text', 'cultivate_base_theme' ),
    'name_admin_bar' => _x( 'Vehicles', 'Add New on Toolbar', 'cultivate_base_theme' ),
    'add_new' => __( 'Add New', 'cultivate_base_theme' ),
    'add_new_item' => __( 'Add New Vehicle', 'cultivate_base_theme' ),
    'new_item' => __( 'New Vehicle', 'cultivate_base_theme' ),
    'edit_item' => __( 'Edit Vehicle', 'cultivate_base_theme' ),
    'view_item' => __( 'View Vehicle', 'cultivate_base_theme' ),
    'all_items' => __( 'All Vehicles', 'cultivate_base_theme' ),
    'search_items' => __( 'Search Vehicles', 'cultivate_base_theme' ),
    'parent_item_colon' => __( 'Parent Vehicle:', 'cultivate_base_theme' ),
    'not_found' => __( 'No Vehicles found.', 'cultivate_base_theme' ),
    'not_found_in_trash' => __( 'No Vehicles found in Trash.', 'cultivate_base_theme' ),
    'featured_image' => _x( 'Vehicle Image', 'cultivate_base_theme' ),
    'set_featured_image' => _x( 'Set Vehicle image', 'cultivate_base_theme' ),
    'remove_featured_image' => _x( 'Remove Vehicle image', 'cultivate_base_theme' ),
    'use_featured_image' => _x( 'Use as Vehicle image', 'cultivate_base_theme' ),
    );

    $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'taxis-for-sale' ),
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'revisions' ),
    'menu_icon' => 'dashicons-car',
    'taxonomies' => array( 'manufacturers' ),
    );

    register_post_type( 'vehicles', $args );

    This is the custom taxonomy code

    $labels = array(
    'name' => _x( 'Manufacturers', 'taxonomy general name', 'cultivate_base_theme' ),
    'singular_name' => _x( 'Manufacturer', 'taxonomy singular name', 'cultivate_base_theme' ),
    'search_items' => __( 'Search Manufacturers', 'cultivate_base_theme' ),
    'all_items' => __( 'All Manufacturers', 'cultivate_base_theme' ),
    'parent_item' => __( 'Parent Manufacturer', 'cultivate_base_theme' ),
    'parent_item_colon' => __( 'Parent Manufacturer:', 'cultivate_base_theme' ),
    'edit_item' => __( 'Edit Manufacturer', 'cultivate_base_theme' ),
    'update_item' => __( 'Update Manufacturer', 'cultivate_base_theme' ),
    'add_new_item' => __( 'Add New Manufacturer', 'cultivate_base_theme' ),
    'new_item_name' => __( 'New Manufacturer Name', 'cultivate_base_theme' ),
    'menu_name' => __( 'Manufacturers', 'cultivate_base_theme' ),
    );

    $args = array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'manufacturers' ),
    );

    register_taxonomy( 'manufacturers', array( 'vehicles' ), $args );

    Is there a mistake in my code, or is this a bug in WordPress?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I don’t quite understand your problem. When editing, the data records of your taxonomy are displayed. They are displayed as checkboxes so that you can select several of them and assign them to the selected posts. What kind of display do you actually expect here?

    Thread Starter paulburrows

    (@paulburrows)

    Thanks for looking at this.

    As you can see from the first screenshot the posts have a taxonomy selected already. When you bulk edit I would expect those taxonomies to either have a tick or a dash in the checkbox as the taxonomy is already set on them.

    This is a screenshot of the standard posts, which work in exactly that way

    This is currently not working on my custom post type.

    Now I understand what you mean. The status of that check mark there. I just had a look at the source code in WordPress. This is controlled via JavaScript and they count the assignments of the categories to the posts as far as I can see. I can’t see that any taxonomy or CPT-specific setting should be necessary there.

    It would be interesting to see the source code you used in full. Can you make it available at https://gist.github.com, for example?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.