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)
Related Posts:
- Show posts without term
- Why is my WP_Query not working when tax_query terms are an array?
- Get list of posts which have at least one term from a custom taxonomy with WP_Query
- List taxonomy terms plus their latest post ordered by post date
- Get random terms
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Order terms inside a select dropdown
- Add a default meta_value to new posts
- Get array of current post term ID’s
- How to add terms to my tax_query based off of the current post
- Change default ordering of taxonomy terms – pre_get_terms
- Empty tax_query array returns an empty array
- Pass array of taxonomy terms to wp_query
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- WordPress Related Post by tags in Single.php
- Function get_queried_object() return NULL in custom taxonomy
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- How to order posts by title after they have already been sorted by category
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Taxonomy order exception for specific term
- Filter Custom Taxonomy Posts
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- get_the_terms – but only show 4 Posts
- Count posts per taxonomy else change taxonomy if less than x number
- How to add custom meta to ‘pre_get_terms’?
- get term id from term name
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to print term name inside wp post loop
- Using WP_Query for categories instead of get_terms
- Check if a post has term inside loop
- Grabbing taxonomy terms and inserting them into an array
- Create one-use post dynamically, add to main query, do not insert post (user profile view)
- Can’t get term id for category archive
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Only show tag with the same id as the post
- display ACF repater field in archive page
- Save queried result into database
- WP Query by 4 different taxonomies
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- Get categories within specific term
- How to display Woocommerce products list by tag
- wp_insert_post with ACF Fields and WP Meta Query returns no rows until update
- taxquery taxonomy get terms
- get term objects and post objects in query
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- Wrote a WP Cron Plugin and it triggers a fatal error upon activation
- Add a custom variable to query page object
- How to get several fields from wp_query?
- query only direct child and sub-terms of a current term archive
- Get access to all terms associated to each post that the wp_query loop displays
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- I need to get all categories from a WP_Query
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Modify WordPress Search
- What kind of object type is WP_Query?
- Show two random posts from custom post type
- Duplicate Queries
- Counting number of posts with Category B in Category A
- pagination doesn’t show up for custom post type
- How to modify query so it grabs only 90 posts in total?
- Placing a div or img in between a post array using WP Query [closed]
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Trying to check and see if a post has a featured image outside of the main loop
- Using pre_get_posts on a specific core/query block
- Efficient way to update multiple post meta
- How to use Meta Value Compare in WP_Query For Max and Min numbers
- Get number of authors
- Wp_query Add specific pending posts
- meta_query not working as expected
- exclude a post from wp_query loop
- Is_single() conditional tag returns null in query
- Is it possible to query a custom field where the value is between two fields?
- WP_Query args to show posts from specific custom taxonomy
- filter wp_query result with custom field values
- All blog data on a page using custom query gives 404 for page 2 and onward
- construct complex queries with WP User Query
- How do I fit WP_Query arguments into a function?
- Date not appearing in custom query
- Custom post type – filter content by custom meta box content
- Trying to output content from page, works locally but not online
- Custom order of posts in wp_query and different taxonomies
- Is meta_key used for ordering, filtering, or both?
- compare for multiple meta values for same key in wp_query
- Taxonomy Terms That Don’t Exist Display Results
- Add pagination to table generated by wp_query
- using next-page and previous page inside a wp_query
- restrict posts per page
- WordPress extremely slow when using get_posts with multiple meta_query relations