Don't dupe categories when adding new ones, use the existing ID.

git-svn-id: https://develop.svn.wordpress.org/trunk@5148 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2007-03-31 05:22:10 +00:00
parent 06e885f4b1
commit 4e3b757f81
1 changed files with 4 additions and 0 deletions

View File

@ -121,6 +121,10 @@ function wp_insert_category($catarr) {
else
$links_private = 0;
// Let's check if we have this category already, if so just do an update
if ( $cat_ID = $wpdb->get_var( "SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' " ) )
$update = true;
if (!$update) {
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
$cat_ID = (int) $wpdb->insert_id;