You want wp_remove_object_terms()
.
if ($category->name == "Uncategorized") {
wp_remove_object_terms( $post_ID, 'uncategorized', 'category' );
}
Untested but “Attachments” are pretty much just posts under the hood, so I am fairly sure that should work.
Related Posts:
- WordPress Multisite – global categories
- Get posts from sites in Multisite?
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Can’t custom taxonomies have same terms (slugs) as categories?
- Using wp_category_checklist in a widget
- How to show subcategories in categories else show posts
- How to remove the parentheses from the category widget
- Filter front page posts by category
- How to get the url to tag & category base set by the user?
- Exclude one category from get_the_term_list
- WordPress remove separator from last item in wp_list_categories
- Filter categories using tags
- Need help adding custom field to category
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- How to display a list of categories
- Root level category, tag, author and archive pages to work
- Number of posts in page – set per category and exclude sidebar
- Create single.php for specific category by category id
- is_category in pre_get_posts results in php notices
- Conditional Tag for sub cagtegories?
- Display only posts from referred category on date archive page
- Sort post’s categories by ID
- in_category() not working in WordPress 4.9.7
- Set the default category of an attachment
- exclude post from displaying in loop if it is in a category, but not in many categories
- Show Featured products in product category pages
- Set post categories to include parents when setting child category
- How to remove category titles?
- Inserting Category programmatically
- Category-slug.php not being used
- Get only one of the current categories
- Show Available Taxonomy List with Current Category
- How to get grandparent of a given category
- Additional form options based on category selected not working
- Pagination for category slug returns 404 when page >= 2
- Display category-specific comments in sidebar
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Paging not working in category.php
- Updating category template to change how subcategories display
- Create menu / submenu from category subcategory and posts
- Display list of categories filtered by date?
- Add a custom category page in WordPress.org
- Remove the parent name from permalink
- Make parent category an optgroup
- Redirect single article permalink to paginated category page
- wp_dropdown_categories not showing option as selected
- Exclude category by slug in pre_get_posts?
- How to check if a post belongs to a category that has only 1 posts?
- add slug beside name in Admin Category Checklists
- How do I use just one category’ posts on my home page?
- List only categories i specify
- Author Page – List of categories plus number of posts in that category
- How can I display tags as categories?
- On the Blogpost I have categories showing, is there a way to exclude a catgegory like ‘Media’?
- How can you access category information from a theme?
- Set category page title in custom theme [closed]
- Filter WooCommerce archive pages by an additional category
- Posts from a category on homepage with category archieves page default css
- How to use wp_list_categories with plugin category?
- Theme modification for custom category menus
- Custom css per category and per single post belong in each category
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Category Page Template – Can’t get category ID
- Limit Loop to One Category
- wordpress taxonomy query posts
- Subcategory is displayed before Parent Category
- Shortcode to display all the post from a category in a page
- How to display WooCommerce category image in my category page banner as a background?
- Custom Loop with certain number of one category
- “Special” category is displayed in all categories or show parent category on sub category
- How to show WooCommerce Categories on ‘shop’ page instead of products?
- How to list all subcategories from all categories but not from a certain category
- add woocommerce archive description if exist
- Can’t display posts by filtering categories using isotope.js
- Get a list of categories, separated by / to display inside the for custom metatags
- Automatically create tags and merge with categories
- Is there a reason to put a product in both the Child and Parent Categories?
- Get_term_meta() always returns false
- How to list all categories a post is in, but exclude current post´s category on single post page
- Get only children category name
- Displaying only selected categories
- No results found for second level category
- get_the_category vs wp_get_post_categories
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Categories in media library
- WordPress Shop and restricting products and categories for some users/groups
- Pass list of categories to JS
- WP url to get rss with full text of post
- WP_query exclude a category unless it has more than one catagory
- Paginating a list of all posts collected by category titles
- Display deepest post category, when post have multiple categories
- Customize category query in widget
- Page permalink rewrite
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- How to control order when displaying child categories
- Broken category styling
- Trying to WP_Query a category
- Woocommerce Force the category choice before creating new product? [duplicate]
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error