From f603da47b6458cd3c98ee9f63f3ddf517db6a575 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: http://svn.automattic.com/wordpress/trunk@5246 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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