Skip to content

Instantly share code, notes, and snippets.

@pbearne
Created May 28, 2021 18:43
Show Gist options
  • Save pbearne/03c7d61604ecb8aac913d4eafd16af39 to your computer and use it in GitHub Desktop.
Save pbearne/03c7d61604ecb8aac913d4eafd16af39 to your computer and use it in GitHub Desktop.
add_action( 'init', function (){
if( isset( $_REQUEST['count_terms'] ) ){
$update_taxonomies = get_taxonomies(['object_type' => ['matador-job-listings']]);
foreach ($update_taxonomies as $update_taxonomy) {
$get_terms_args = array(
'taxonomy' => $update_taxonomy,
'fields' => 'ids',
'hide_empty' => false,
);
$update_terms = get_terms($get_terms_args);
echo $update_taxonomy . ' has ' . count( $update_terms ) .' terms' . PHP_EOL . PHP_EOL;
wp_update_term_count_now( $update_terms, $update_taxonomy );
}
die();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment