Make WordPress Core

Changeset 5246

Timestamp:
04/12/2007 01:49:46 AM (17 years ago)
Author:
rob1n
Message:

Use cat_name instead of cat_nicename when creating categories from import. Props takayukister. fixes #4040

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/wordpress.php

    r5245 r5246  
    289289            if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
    290290                $this->posts_processed[$post_ID][1] = $post_id; // New ID.
    291 
     291           
    292292            // Add categories.
    293             if ( 0 != count($categories) )
    294                 wp_create_categories($categories, $post_id);
    295                
     293            if (count($categories) > 0) {
     294                $post_cats = array();
     295                foreach ($categories as $category) {
     296                    $cat_ID = (int) $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE cat_name = '$category'");
     297                    if ($cat_ID == 0) {
     298                        if ($cat_ID = wp_insert_category(array('cat_name' => $category))) {
     299                            $post_cats[] = $cat_ID;
     300                        }
     301                    }
     302                }
     303                wp_set_post_categories($post_ID, $post_cats);
     304            }   
    296305        }
    297306
Note: See TracChangeset for help on using the changeset viewer.