WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

#48454 closed defect (bug) (duplicate)

Term count incorrect for custom taxonomy on attachments

Reported by: powerbuoy Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.2.4
Component: Taxonomy Keywords:
Focuses: Cc:

Description

When creating a custom taxonomy for the 'attachment' post-type its term counts aren't properly updated.

To reproduce:

1) Download and install WordPress 5.2.4 with the twentynineteen theme

2) Add a custom taxonomy:

<?php
add_action('init', function () {
        register_taxonomy('attachment_category', 'attachment', [
                'labels' => [
                        'name' => 'Attachment categories',
                        'singular_name' => 'Attachment category'
                ],
                'rewrite' => [
                        'with_front' => false,
                        'slug' => 'attachment-categories',
                        'hierarchical' => true
                ],
                'hierarchical' => true,
                'sort' => true,
                'show_in_rest' => true,
                'show_admin_column' => true
        ]);
});

3) Create some taxonomies and assign them to media:

4) Notice how term count still says zero:

Attachments (4)

Screenshot 2019-10-29 at 03.59.21.png (32.4 KB) - added by powerbuoy 7 months ago.
Latest WordPress - clean install
Screenshot 2019-10-29 at 03.59.50.png (21.2 KB) - added by powerbuoy 7 months ago.
Taxonomy created
Screenshot 2019-10-29 at 04.00.02.png (191.4 KB) - added by powerbuoy 7 months ago.
Assign terms to attachments
Screenshot 2019-10-29 at 03.59.44.png (43.9 KB) - added by powerbuoy 7 months ago.
Term count still incorrect

Download all attachments as: .zip

Change History (5)

@powerbuoy
7 months ago

Latest WordPress - clean install

@powerbuoy
7 months ago

Taxonomy created

@powerbuoy
7 months ago

Assign terms to attachments

@powerbuoy
7 months ago

Term count still incorrect

#1 @SergeyBiryukov
7 months ago

  • Component changed from General to Taxonomy
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #22558.

Note: See TracTickets for help on using tickets.