Community & Support

Creating a new taxonomy term dynamically using PHP

Hi,

I'm trying to write a script that saves a new taxonomy term. How should I do this? taxonomy_save_term? taxonomy_term_submit?

thanks.

Comments

check out these modules

check out these modules:
taxonomy_csv - function taxonomy_csv_import_line
install_profile_api - function install_taxonomy_add_term

both of them use taxonomy_save_term

Yes, that helped. Thanks.

Yes, that helped. Thanks.

Sample Code

Here is the sample code you can use

$new_term_cat = array();
$new_term_cat['name'] =  'category name';
$new_term_cat['vid'] = $vid;   / / vocab id
$new_term_cat['parent'] = 0;
$new_term_cat['weight'] = 0;
taxonomy_save_term($new_term_cat);

Thanks,

Suro
http://www.drupalextras.com/

Thanks both of you that

Thanks both of you that worked.

nobody click here