WordPress.org

Ready to get started?Download WordPress

Forums

WP Ultimate CSV Importer Plugin
[resolved] Categories are created even if the CSV file contains category IDs (2 posts)

  1. shark0der
    Member
    Posted 1 year ago #

    This is happening because wp_set_object_terms uses is_int to check for whether items are IDs or category names. After splitting the categories string using "|" the plugins should cast numeric values to int.

    This code fixes the issue:

    // Create/Add category to post
    if(!empty($categories)){
       $split_line = explode('|',$categories['post_category']);
       foreach($split_line as &$val){
          if(is_numeric($val)){
             $val = (int)$val;
          }
       }
       wp_set_object_terms($post_id, $split_line, 'category');
    }  // End of code to add category

    http://wordpress.org/extend/plugins/wp-ultimate-csv-importer/

  2. smackcoders
    Member
    Plugin Author

    Posted 1 year ago #

    shark0der, Thanks for the update and the code fix. New version is released. Please upgrade and leave your feedback.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.