Opened 12 years ago
Closed 12 years ago
#23530 closed defect (bug) (duplicate)
Attachment taxonomies, $term->count not working
Reported by: | paddelboot | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Backend:
- Register an attachment taxonomy
- Create a taxonomy term
- Upload an attachment and check the box of the newly created term, save.
- Go to the attachment taxonomie's overview
- Under "Media", it shows 0
- Click on "0", and you should see the attachment in the overview.
Code:
register_taxonomy( 'attachment_directories', 'attachment' ); $term = wp_insert_term( 'parent', 'attachment_directories' ); $args = array( 'post_title' => 'dummy-attachment', 'post_content' => '', 'post_status' => 'inherit', 'post_mime_type' => 'image/jpeg', 'post_author' => '1' ); $id = wp_insert_attachment( $args ); wp_set_object_terms( $id, $term[ 'term_id' ], 'attachment_directories' ); $args = array( 'hide_empty' => TRUE, 'fields' => 'ids' ); $non_empty_directories = get_terms( 'attachment_directories', $args ); //$non_empty_directories is an empty array(), but it should return the ID of the 'parent' term.
Change History (6)
#3
@
12 years ago
It seems to have something to do with whether the attachment is attached to a post or other object or not.
- Editing an unattached media file and selecting a taxonomy term for it does not, after saving, increase this term's counter
- Un-selecting the taxonomy term, saving the media file, attaching the media file to something, and again selecting the taxonomy tag does, after saving, increase the term's counter
Is this in any way wanted?
Note: See
TracTickets for help on using
tickets.
Of course last line should be:
$non_empty_directories = get_terms( 'attachment_directories', $args );
instead of:
$non_empty_directories = get_terms( 'attachment_directories', $args3 );