I'm using a feed aggregator combined with an auto-tagger for tracking words in a stream.

I'm using WP-Cumulus to generate a pretty tag cloud based on these.

However, I want to keep the tag cloud "fresh", at the moment it's showing "all-time" tag use.

I want it to show tag use for, for example, the 100 newest entries.

To do this, I think I might do the following:

  1. Write a bit of php that deletes all entries except the 100 newest entries, when there are more than 100 entries.
  2. Trigger re-count of tags.

Will this work? How can I trigger a re-count? Does it happen with every new post? Or am I doing it all wrong?

Thanks in advance for your advice.

1 Answer 1


You can call wp_update_term_count_now( $terms, $taxonomy ) (documentation) to update the term count for the specified terms (you will need to pass an array of all terms if you want to update them all).

If you want to use your own function instead of the standard function (which counts all posts), you can set the update_count_callback of the taxonomy. The function you specify here will be used instead.

Remember, the tags are configured like any other (custom) taxonomy, so you can change their parameters too. It is registered in the global $wp_taxonomies array with the post_tag key.

  • That might be a good place to start. My problem, though, is I need to re-count everything, not just a specified array of tags. Something like: 1. Post new entries 2. Reset all tag counts 3. Remove posts older than "x" newest posts 4. Count tags I'm going to have to roll my sleeves up then?
    – puppybeard
    Mar 4, 2011 at 14:52
  • @puppybeard: This indeed just a start. You'll have to figure out yourself when you want to refresh the tag counts: every time you save a post, once daily, once every week? But you will still need to override the update_count_callback with your own function.
    – Jan Fabry
    Mar 4, 2011 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.