Best action hook to create custom post and assign taxonomy terms to it on plugin activation?

When I install the plugin, I want to create 10 CPTs of a particular type, which I define in the init action hook, and want to assign 10 terms of a custom taxonomy, which too is defined in an init callback. I tried doing it on register_activation_hook, but the CPT's terms are not set. Is there a way to achieve this?

Topic custom-taxonomy init plugins custom-post-types Wordpress

Category Web


According to the docs, I needed to set the terms using post ID. So after every insert, I used the ID to set the terms https://codex.wordpress.org/Function_Reference/wp_set_post_terms

Someone might find this useful.

About

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