[wp-trac] Re: [WordPress Trac] #3460: Duplicated default category
after deleting a category
WordPress Trac
wp-trac at lists.automattic.com
Sun Dec 10 20:43:08 GMT 2006
#3460: Duplicated default category after deleting a category
----------------------------+-----------------------------------------------
Reporter: zhouqb | Owner: markjaquith
Type: defect | Status: assigned
Priority: normal | Milestone: 2.0.7
Component: Administration | Version: 2.0.5
Severity: normal | Resolution:
Keywords: category |
----------------------------+-----------------------------------------------
Changes (by markjaquith):
* status: new => assigned
* owner: anonymous => markjaquith
* milestone: 2.1 => 2.0.7
Comment:
This has been fixed for 2.1
Possible 2.0.7 milestone.
Here is the 2.1 code, for reference:
{{{
// Only set posts and links to the default category if they're not
in another category already.
$default_cat = get_option('default_category');
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE
category_id='$cat_ID'");
if ( is_array($posts) ) foreach ($posts as $post_id) {
$cats = wp_get_post_categories($post_id);
if ( 1 == count($cats) )
$cats = array($default_cat);
else
$cats = array_diff($cats, array($cat_ID));
wp_set_post_categories($post_id, $cats);
}
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/3460#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list