I think the function you are looking for is called wp_insert_term() in WordPress core.
Woocommerce uses WordPress-taxonomy called product_cat
So if you want to add some categories for example phones
:
function wpse_insert_term()
{
wp_insert_term(
'phones',
'product_cat', // the taxonomy
array(
'description'=> 'A yummy phone.',
'slug' => 'phone',
)
);
}
add_action('init', 'wpse_insert_term');
Related Posts:
- WooCommerce: List All Categories
- Combine two taxonomies in a hierarchical tree
- Woocommerce product categories order [closed]
- How to split the categories of subcategories with thumbnails
- WooCommerce – Display product child categories from specific parent
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- Display products for a category, sorted by post_excerpt
- Woocommerce – Get product category 2nd level category
- How do you remove display of WooCommerce product category on single product page?
- Show Featured products in product category pages
- Show category images on single product page and product overview page
- woocommerce product category tabs [closed]
- Get Tags specific to Category using WooCommerce plugin
- How to change how many list item show in category generated by file edit-tags.php
- Show button only for certain Woocommerce Product Categories
- Target a specific category from a custom taxonomy?
- How to display product categories and number of sales on WooCommerce
- show category in woocommerce
- List products from current category
- Display all subcategories for a product category in woocommerce
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- WooCommerce Product Search Error
- Add product category to post_class
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Gutenberg editor add a custom category as wrapper for custom blocks
- Different template for subcategories
- WP_Query not looking at child category
- Deleting default category in wordpress
- Most recent post from every category/taxonomy but sorted by date
- Category Archive, list subcategories of each post
- Disable pagination only for specific category
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Check if post belongs to any category
- How to display get_the_category of post showing only CHILD of category “X”
- Get ID of current taxonomy in register_rest_field
- display woocommerce all category title on home page
- Custom page for WooCommerce’s /product-category/
- get all sub categories without specify any category
- How to use wp_category_checklist()?
- Get the name an the description of a link category
- Display child categories in WooCommerce
- WooCommerce duplicate sub categories and product slugs
- Check child/parent categories if exists
- How to run select query of post with category and tags for API?
- How to show only one category in breadcrumb navigation
- Populate dropdown based on selection of parent category
- query cat orderby and order not working
- WooCommerce – How to show specific category first-rest of products-specific category last
- Multiple URL’s based on category for one post
- WordPress category check
- How to display taxonomy images with wp_list_categories?
- How can I improve this taxonomy treating approach?
- Exclude categories from wp_list_categories by category slug
- Can’t delete a category in WordPress
- Dropdown Categories used in form shows no results when all is selected
- Nicer URL for viewing category of posts?
- Get Categories Where Taxonomy Equals ‘n’
- Odd results in get_the_terms vs wp_get_post_terms
- How to access deleted term inside delete_product_cat action
- get full category structure by post id
- Remove Archive | from Categories
- Showing Categories for Page Edit – without plugin
- Using categories with pages
- Show next post in same category but start from the latest
- Only first category!
- How could I write a get_categories_by_year() function?
- How to add icon over specific thumb
- Echo Category Nicename
- Explode() expects a string
- How to add meta description, keywords, custom title to a category template
- User level categories
- Exclude category from drop down list form
- How to set the same base url for two different taxonomies?
- Precheck fields when I add a new post
- Programmatically Create Category and sub Category and sub sub Category
- Parent Category and Subcategory default text generated with category
- How to create a table with counts of category combinations?
- How to get the_category(‘, ‘) with link “title” attribute
- product_cat image url from database
- How to get the term id inside the start lvl method of category walker?
- Multiple if statements with else for get_the_category [closed]
- Most efficient way to display current post subcategories?
- Using a template page parent breaks page
- How to Query the Top 5 Posts of a specific category?
- Setting category for post as default
- How to add a post with new Taxonomy without assigning to default category?
- Query post only from categories that have subcategories
- How to get the link of all categories
- foreach,having wp_query inside, breaks after showing one result
- 2 loops in archive.php (one for each category)
- How to load jquery tag-it plugin into admin?
- Include Category Description in search result
- not empty categories don’t show in menu [closed]
- Show parent-child relationship for categories in the wordpress admin
- How to assign different categories to pages in wordpress?
- Automatically set posts to NoIndex depending on category?
- All post of child category not in top category
- How to add a tag above a category post that displays the category name in WordPress
- Woocommerce – Display product category of product in Orders page
- How to link ACF relationship field to the new Query block in Full Site Editing