Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#13670 closed defect (bug) (fixed)

Taxonomies for custom Post_Types do not recieve pad_counts treatment

Reported by: dd32's profile dd32 Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: needs-patch
Focuses: Cc:


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)

#1 @reko
14 years ago

With this patch, _pad_term_counts() queries the post_type(s) of passed taxonomy instead of just post_type = 'post'.

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'");

#2 @nacin
14 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.

#3 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [15108]) Make _pad_term_counts custom post type aware. Props reko. fixes #13670

#4 @ryan
14 years ago

(In [15110]) Remove debug. fixes #13670

Note: See TracTickets for help on using tickets.