WP_Error on attribute + term insert
-
Hello,
I want to add a product attribute (wc_create_attribute) & assigned terms (wp_insert_term) via the functions.php.
Example:
$args = array( 'name' => "Color", 'slug' => "color", 'order_by' => "menu_order", 'has_archives' => "", ); wc_create_attribute($args); $add = wp_insert_term( "Blue", 'pa_color', array( 'slug' => "blue" ) ); print_r($add);The wc_create_attribute works fine, but when the wp_insert_term runs it throws an error because of “Invalid taxonomy”.
When I then reload the page, it works fine because then the taxonomy is not invalid anymore.
So it seems that the wp_insert_term are executed before the create_attribute somehow. I don’t understand why it does not work in one attempt.Maybe you can help me
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘WP_Error on attribute + term insert’ is closed to new replies.