I have a 1000+ terms I need to add to a taxonomy called county
. I am trying to use this function
wp_insert_term but the term is not being added to the database. I am running this code inside function.php
as a test before looping over each unique term. Should I be using a specific hook?
wp_insert_term(
'Maricopa',
'county',
array(
'description'=> 'Maricopa',
'slug' => 'maricopa'
)
);
Also curious of other ways of adding multiple terms at once. Is there a REST API option for doing this?
EDIT
Tried using this hook but same result the term was not added to the 'county' taxonomy.
function add_county_terms() {
wp_insert_term( 'Maricopa', 'county', array(
'slug' => 'maricopa',
));
}
add_action( 'wp_loaded', 'add_county_terms' );