Updates the number of posts attached to a term (taxonomy element). The types of posts to consider are taken from the taxonomy settings.
The function is responsible for updating the post count in the term (tags or categories) for a specific taxonomy related to posts. The function counts the number of posts associated with each term and updates this value in the database.
Such updates occur automatically when creating/updating a post linked to the taxonomy or when adding/removing a term.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
Since _update_post_term_count() is an internal WordPress function and it is dangerous to use it directly in theme or plugin code, the example of using this function is based on its application within the function register_taxonomy().
In the example, a new taxonomy "genre" is created for post entries, and the function _update_post_term_count() is used to count the number of posts associated with each term in this taxonomy.
In this example, _update_post_term_count will be called immediately after the number of posts associated with any term from the “genre” taxonomy is changed, ensuring an accurate count of associated posts for each term.