0

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?

1

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)

  • 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. :) – fuxia 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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