You pass the array of WP_Term
objects instead of the array of term_id
to the wp_update_term_count_now()
.
Pass the fields
argument to get_terms()
to specify it’s output:
<?php
$update_taxonomy = 'post_tag';
$get_terms_args = array(
'taxonomy' => $update_taxonomy,
'hide_empty' => false,
'fields' => 'ids', // nota bene.
);
$update_terms = get_terms( $get_terms_args ); // get the array of term IDs.
wp_update_term_count_now( $update_terms, $update_taxonomy );