Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

what wp function do i use so that I can delete a term without worrying about the related tables such as wp term relationships and wp term taxonomy?

Also if a post has a relationship to the deleted term and it's the only relationship to any term does wp take care of the necessary and it's associated back to uncategorized ? What if there is no uncategorized term neither?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use this: wp_delete_term

Edit: Did a little dig around. With custom taxonomies, if you delete the term, the posts will not be assigned a new one. With 'category', whichever you set as the default from 'Writing Settings' will be assigned to the post. Besides, if you want to set the default category from code, use update_option('default_category', '<category name>'). There's a third argument with wp_delete_term, using which you can force a default category, but I really couldn't find how to use this argument. (Ref: ../wp-includes/taxonomy.php, l. no. 1681)

share|improve this answer
    
Also if a post has a relationship to the deleted term and it's the only relationship to any term does wp take care of the necessary and it's associated back to uncategorized ? What if there is no uncategorized term neither? –  Average Joe Apr 13 '12 at 6:08
    
I guess I'll have to look at it with an example! –  Rutwick Gangurde Apr 13 '12 at 6:37
    
Yes please. This answer has a quality score of 56. You can do better. Always, always add a code example. :) –  toscho Apr 13 '12 at 8:17
    
Thanks! Have edited my answer a bit... couldn't get an example though! –  Rutwick Gangurde Apr 13 '12 at 10:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.