• Hello!

    I am trying to import a CSV File into custom content types in WordPress 3. It works fine, only I am trying to create new terms in my custom taxonomy for the values in one of the CSV Columns.

    It seems that I cannot insert new terms using wp_insert_term from anywhere except within the init() stage of WP.

    When I use the following function, it will not add:
    /** Upload **/
    $uploaded= @$_POST[‘hidden_uploaded’];
    $content_type= @$_POST[‘content_type’];
    $csv_file= @$_FILES[‘file_csv’][‘tmp_name’];

    if(isset($uploaded)){
    $result = price_read_csv($csv_file, $content_type);
    $category_id= wp_insert_term(‘Containers’, ‘price_products_category’);
    echo $result;
    }

    This is in the main plugin file, so basically if the $uploaded variable is set (after the user submits the upload form) it runs the csv function and tries to add a hard coded category… However this will not work, do new terms have to be added at a particular stage or can they can be added when needed?

    Thanks much!!

  • The topic ‘Insert Term Question’ is closed to new replies.