Use register_taxonomy() in register_activation_hook()

Is the data not stored in the database but rather in memory?

Taxonomies (like post types) aren’t store in database and needs to be registered on every page load. The build in taxonomies, category and post_tag are actually registered twice, the second time on the init hook.

The init hook is the earliest to register taxonomies and post types because this is the hook where localization becomes available. This has become the accepted hook to register post types and taxonomies.

If so, might such taxonomies become memory hogs?

No. If you are going to register tons of taxonomies (or post types) it might become an issue, but doing that would point to a flaw in your design.

Terms on the other hand needs to be be registered once as they are stored in db. Here the register_activation_hook() is useful to register terms on plugin activation. Here is an example on how to register terms on plugin activation

Leave a Comment