Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#21639 closed defect (bug) (duplicate)

wp_update_term doesn't honor taxonomy

Reported by: Whissi Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3
Component: Taxonomy Keywords:
Focuses: Cc:



I wanted to programmatically change my categories. This is the code I would use:

foreach ( $categories_to_rename AS $category ) {
        $cat_ID = (int) $category->cat_ID;
        if ( $cat_ID === 1 ) {
                // Skip default category
        $updatedCategory = array();
        $updatedCategory['slug'] = getTheNewCategoryNameFromSomewhere( $cat_ID );
        $update_response = wp_update_term( $cat_ID, 'category', $updatedCategory )
        if ( is_wp_error( $update_response ) )
                return $update_response;

After that I noticed, that the slug of some tags were changed, too.

I looked into the database and noticed, that some tags shared the same term with a category. Because I updated the slug, which is stored in the terms table, the tag name was "updated", too.

This is something I don't expect. When I call an update on "category", I don't expect that something else will update, too.

When it is allowed, that a category and a tag will share the same term, this sharing should end when you update just one part.

Change History (2)

#1 @wonderboymusic
9 years ago

  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from 3.4.1 to 2.3

dupe of #5809

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.