With wp-cli installed you can run a bash script like this to remove the ‘uncategorized’ category from all posts with more than one category
#!/bin/bash
for post in $(wp post list --field=ID)
do
count=$(wp post term list $post 'category' --fields="name" --format="count")
if [ "$count" -gt "1" ]
then
wp post term remove $post category 'uncategorized'
fi
done
Save this as something like delete_uncategorized.bash
and then run bash delete_uncategorized.bash
from the command line.
Related Posts:
- On the category page, get the category object
- Display Image for a category using get_categories, or show an image from any child post
- Group WP_Query by category
- Decreasing the Memory Consumption of a WordPress Site?
- How to filter categories by custom field?
- get_terms name__like list categories according to letter
- Adding Colorpicker Field To Category
- Add extra fields to Add New Category page
- get_categories returns an array with one category
- Different templates for parent and children categories/taxonomies
- How to make a relationship between books and authors?
- Create a full width responsive header image per page
- How to create tabled index of posts in a certain category
- Remove child products from woocommerce category page [closed]
- Display comments on a comment page without form
- Plural Category Base Slug On Category Archive Page
- WP 3.0.5: Best way to add custom metaboxes for post categories?
- How do I view a feed consisting of posts from multiple categories?
- Marking old posts as no longer relevant
- Unpublish all posts in a category
- Any way to assign Post Categories and Tags to Links?
- Add class to items in wp_list_categories()
- How is the single category page called and how does it know which posts to show?
- How to export/import categories and keep their IDs?
- How to create a page that shows posts from multiple categories
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Problem with wp_create_category
- Should the actual /category/ directory be 404? Is that normal WP behaviour
- Redirect category to url with /category
- Extract image url associated to a category
- I Cannot Create New Category
- Archive.php filtered by pre-determined category
- category filter doesn’t work in WPML
- How do you categorize pages?
- Order of subcategories
- “Categories” for six authors [closed]
- Filtering *out* a taxonomy from the admin post list
- category image taxonomy
- Categories overview that links to page displaying posts
- Category control subcategories
- Trying to add cat_ID to array for showing an image for specific Category
- display posts from specific category on a page , in thematic child theme?
- Hidde certain category from post meta
- How to add a post without assigning to a category?
- List all posts in a category with query_post() function
- How to change amount of categories listed on dashboard?
- How to display parents category and child category separately for a specific post?
- Display random categories
- Get a count of how many times a term or a category is used in posts
- Exclude a category name using cat name
- Get custom title if category
- Link To Child Category For A Post
- Post by category+author not working!
- Custom template for sub-sub-categories
- Simple way to style posts of a single category differently in the loop and in single
- show WordPress categories with different Structure
- How to remove the tilte “category:category name”?
- why category__and and category__in wont work togather?
- wp_dropdown_categories initial value
- Advanced permalinks structure
- Subcategory Page URL to Display Only Posts from that Subcategory?
- Setting the Primary Category for a Post Based on Context
- How can I display image child category in parent
- Limit categories to hierarchal depth of 2
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Shop Category Pages missing s
- ADD DYNAMIC attribute for category to accordion
- How to prevent tag “iframe” from being deleted from the heading description of rubric?
- Unable to add multiple categories to a post in WordPress
- How to display custom fields as table in Woocommerce
- make color of headline depend on category?
- Menu with category 2 category combined
- Some subcategories not working on custom portfolio sort
- How can I make a category function as a page?
- Link For Portfolio Categories
- Displaying Category in sidebar post widget but not in the loop on home
- Create duplicate category page with content variations
- Renaming default category taxonomy?
- Media Categories as Classes on WordPress Gallery Shortcode
- Category names dependent on each other?
- Category Template for Custom Post Type
- Loop Through Categories in Custom Field
- Backend – Categories and Menus conflicts
- get categories the post was in and just been removed from
- Loop through posts of CatA and store value of CatB in separate array
- Highlight posts that belong to current sub category
- How to add an empty entry to masonry?
- How to enable admins/editors to set a featured image for specific category?
- Problem with single posts not showing correct category sidebar
- Multiple Categories under one URL, where ‘Front Page’ is used already
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- How to display many photo albums related to category
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Having Trouble With get_category_by_slug In a Custom Function
- WordPress category gives 404 after moving to a different domain
- Create custom Perma link
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?
- Add product category to post_class