tax_input not working wp_insert_post

The most common reason is that you run this code without user context (cron, etc). Within wp_insert_post() context WP will check if user has permissions to a taxonomy. No user equals no permissions equals no terms being assigned.

The workaround is to create post first, then assign terms to it. When terms are assigned explicitly via API method (such as wp_set_object_terms()) the permissions check is not performed.

Leave a Comment