Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ddimaria

    (@ddimaria)

    As a final post, here’s what I ended up doing to preserve the ability to import multiple categories for a single post with commas in the category name:

    $items = array_map(‘trim’, explode(‘|’, $data[‘csv_post_categories’]));

    I just changed the delimiter to a pipe. It’s a hack, but works for my purposes.

    Thread Starter ddimaria

    (@ddimaria)

    I spoke too soon, the problem is with line 301 of the plugin:

    $items = array_map(‘trim’, explode(‘,’, $data[‘csv_post_categories’]));

    I’m not sure why this is in place, but when I replace it with the below code, the categories imported properly:

    $items = array_map(‘trim’, array( $data[‘csv_post_categories’]) );

    Thread Starter ddimaria

    (@ddimaria)

    So, it looks like this is a “feature” of the core. If you look at line 2651 of wp-includes/taxonomy.php:

    $object_ids = explode(‘,’, $object_ids);

    It looks like a hack to the importer is needed to alter to comma prior to injection (maybe [COMMA] or like), then update the terms table after the import is complete. This is assuming that you can have commas in category names in WP.

    Thread Starter ddimaria

    (@ddimaria)

    I traced out the code, and it looks like the code is good. Below is the array I traced out in the create_or_get_categories function. So, it looks like the issue is related to WP’s wp_insert_category function.

    Array
    (
    [0] => Array
    (
    [cat_name] => Toddler
    [category_parent] =>
    )

    [1] => Array
    (
    [cat_name] => Toddler Health & Safety
    [category_parent] =>
    )

    [2] => Array
    (
    [cat_name] => Heath, Complications, & Illness
    [category_parent] =>
    )

    [3] => Array
    (
    [cat_name] => Autism, ADD, & ADHD
    [category_parent] =>
    )

    )

Viewing 4 replies - 1 through 4 (of 4 total)