[Resolved] wp_set_object_terms doesn't work in init?
I’ve written a function to collect some data from the front-end of a site and create a custom post type, then associate that CPT (which is a CPT-onomy) with another CPT using
$cpt_onomy-> wp_set_object_terms( ... )
I was doing this in a function that hooked
init. I ran into an issue where I kept getting a WP Error object returned with the message “Invalid taxonomy”. The CPT-onomy was correctly registered and I checked that the taxonomy was definitely registered by hooking the
registered_taxonomyaction. In the end I tried a later action; Instead of
wp_loadedand my problem vanished.
So I suppose my question is which action do you recommend hooking for this kind of task? What’s the earliest action we can hook such that we don’t get in there before CPT-onomies has had a chance to set everything up appropriately?
Great plugin by the way. Awesome idea and great documentation.
- The topic ‘[Resolved] wp_set_object_terms doesn't work in init?’ is closed to new replies.