get_terms throwing fatal error in some situations
-
Hi,
The fix for the deprecated get_all_category_ids, proposed by @witters below, unfortunately throws a fatal error in some situations.
This is because get_terms returns an array of full term objects, but the function wp_update_term_count only needs (can only accept) the term_ids.
Proposed fix: (changes from line 118-125 in no-future-posts.php)
/** * update post counts in categories */ static function update_count() { // $terms = get_all_category_ids(); // deprecated $terms = get_terms( array( 'taxonomy' => 'category' ) ); if( $terms ) { // build array of just the IDs for wp_update_term_count $term_ids = array(); foreach( $terms as $term ){ $term_ids[] = $term->term_taxonomy_id; } wp_update_term_count($term_ids, 'category'); } }
- The topic ‘get_terms throwing fatal error in some situations’ is closed to new replies.