#13670 closed defect (bug) (fixed)
Taxonomies for custom Post_Types do not recieve pad_counts treatment
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Taxonomy | Keywords: | needs-patch |
Focuses: | Cc: |
Description
as reported by reko in #wordpress-dev, Taxonomy pad_counts do not apply to custom taxonomies, attached to custom post types.
Right now, the SQL limits pad_counts to published posts.
For comparison, The _update_post_term_count()
function (which updates categories and tags counts) limits to published post_type objects in that taxonomy.
Change History (4)
#2
@
15 years ago
function()->property
is PHP 5 only.
We (should) probably have a function that returns the post types a taxonomy is attached to, the same way we have get_object_taxonomies() return the taxonomies attached to a post type.
Note: See
TracTickets for help on using
tickets.
With this patch, _pad_term_counts() queries the post_type(s) of passed taxonomy instead of just post_type = 'post'.
REPLACED
wp-includes\taxonomy.php # 2387 with:
$object_types = is_array(get_taxonomy($taxonomy)->object_type) ? get_taxonomy($taxonomy)->object_type : array(get_taxonomy($taxonomy)->object_type);
$object_types = esc_sql($object_types);
$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'");