From f9ab937ce7e324cfed51766d64536165ef0438c8 Mon Sep 17 00:00:00 2001 From: rob1n Date: Thu, 12 Apr 2007 01:49:46 +0000 Subject: [PATCH] Use cat_name instead of cat_nicename when creating categories from import. Props takayukister. fixes #4040 git-svn-id: https://develop.svn.wordpress.org/trunk@5246 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import/wordpress.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 1be1666faa..46dd4c8e52 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -288,11 +288,20 @@ class WP_Import { // Memorize old and new ID. if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) $this->posts_processed[$post_ID][1] = $post_id; // New ID. - + // Add categories. - if ( 0 != count($categories) ) - wp_create_categories($categories, $post_id); - + if (count($categories) > 0) { + $post_cats = array(); + foreach ($categories as $category) { + $cat_ID = (int) $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE cat_name = '$category'"); + if ($cat_ID == 0) { + if ($cat_ID = wp_insert_category(array('cat_name' => $category))) { + $post_cats[] = $cat_ID; + } + } + } + wp_set_post_categories($post_ID, $post_cats); + } } // Now for comments