When are tags counted? Can it be trigered manually?

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.

Topic feed tags Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.