Last active
August 6, 2018 13:13
-
-
Save GaryJones/a5b9e939a8860308dc54c198dec607db to your computer and use it in GitHub Desktop.
Fix WordPress category (or other taxonomy) counts, after incomplete import, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Can drop into {yourtheme}/functions.php and then hit the site. | |
$update_taxonomy = 'category'; // Set to the correct taxonomy. | |
$get_terms_args = array( | |
'taxonomy' => $update_taxonomy, | |
'fields' => 'ids', | |
'hide_empty' => false, | |
); | |
$update_terms = get_terms( $get_terms_args ); | |
wp_update_term_count_now( $update_terms, $update_taxonomy ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment