To create a taxonomy term programmatically you can use wp_insert_term
function.
<?php wp_insert_term( $term, $taxonomy, $args = array() ); ?>
It has 3 params:
$term (int|string) (required) The term to add or update. Default: None
$taxonomy (string) (required) The taxonomy to which to add the term.
Default: None$args (array|string) (optional) Change the values of the inserted term
Default: None
WooCommerce categories are stored as terms in product_cat
taxonomy, so if you want to create some new category, you can use this code:
wp_insert_term( 'My New Category', 'product_cat', array(
'description' => 'Description for category', // optional
'parent' => 0, // optional
'slug' => 'my-new-category' // optional
) );
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Woocommerce singe product custom gallery output works just on the first slide
- Remove Pagination for Product Category Pages WooCommerce
- woocommerce remove coupon link does not work
- woocommerce: Customize email with item total count
- How can I find related learndash course id from woocommerce product object?
- WooCommerce custom query and paging: Not Found error
- Woocommerce Add Variation Product to Cart from custom link [closed]
- WooCommerce – How to Add a Custom Field to Cart Items and Cart Totals [closed]
- Hide wordpress plugins from list
- Changing Woocommerce Product Description [closed]
- How to hide fields from my user profiles
- How to make my plugin theme-independent?
- how to redirect to my template
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Code in theme functions.php faster than with a plugin?
- Custom Shipping method not showing in checkout
- Workflow and best practice for documentation [closed]
- Show “Local Pickup” shipping method only for specific Woocommerce product categories [closed]
- WP Crowdfunding customization [closed]
- Can’t create term for product attribute
- block countries from shipping to them in WooCommerce [closed]
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How does WP handle multiple matching rewrite rules?
- Add Product Subtitle to Woocommerce Product Page
- WooCommerce shop page orderby [closed]
- How can you include a theme template file from within a plugin (i.e. WooCommerce’s Shop page)?
- Not getting author rank when using return
- What are wsm tables for?
- New databes tables with – WooCommerce – for developers [closed]
- Change commission_status paid when withdraw_status vendor is completed
- Change Product Addon price based on select Variation
- WooCommerce – Maximum qty per line per product
- Woocommerce Create custom product type with variations
- Remove /product/ from url. I want only category name then product name
- Save custom attributes of product in woocommerce
- trying to get product category image in woo-coomerce
- WooCommerce search products between price range using WP_Query
- Exact Hook to payment methods
- Adding Static Image to WooCommerce Content-Single-Product template
- Customizing Titles on the Fly with Code
- Get Every Key & Value from Array then Display All in New Line
- How to add a new column with text fields to WooCommerce Cart List?
- Woocommerce: limit user to see only the products he created
- How do I get the Payzone WooCommerce payment gateway plugin to show up in the settings? [closed]
- Error with get_price (and others) in self-written plugin to show price
- How to change WooCommece variation data programmtically [closed]
- Managing wordpress Themes & plugins for multisite
- .php file for woocommerce edit category? [closed]
- Advanced Custom Fields (acf) – Filter Relationship by Taxonomies not Post Type
- WordPress Multi-Step Product Search
- Woocommerce Free shipping method [closed]
- dynamically create callback functions inside a for loop
- Changing the Organize Series Listing Pages
- What’s the right way to implement functions in footer.php
- WordPress Phone Field Check (use numbers, spaces and pluses)
- Can export gallery but can’t import it Wp all import
- How to get authors who have added the post in the specific custom post type
- Get product categories and add them to a custom taxonomy
- How to Get Category Name When Export Products
- Plugins to generate reflinks in WordPress
- How to override any plugin file in the child theme
- WoCommerce Cart is not showing pricing
- How to add label/badge on bookable product based on their booking status
- How to Fix WordPress multisite woocommerce 403 file error
- Adding discount functionality to the cart
- How to find the file path in WordPress?
- How to get a post views count using ‘WordPress popular posts’ plugin
- Woocommerce Attribute price for non-variations
- Using Shortcode Result In Custom HTML Block (Using Google Sheet JQuery Result As NumScroller data-max)
- Change Woo Custom Endpoint Titles from a Plugin
- Woocommerce functions in custom class, avoid errors
- How to use plugin’s shortcode in custom design? [closed]
- Fetching users data from REST API
- Automatically check “Enable stock management at product level” to the existing products?
- Change hook to add_action in a plugin class
- Product catalogue in WordPress
- Adding/ Removing actions for plugins
- Unable to sync woocommerce variations
- Run one-time script calling plugin functions
- Showing ads in the specific category and its sub-categories
- Breadcrumb is not generating the correct post page url
- Unable to show 4 products in a row
- Woocommerce quick checkout form [closed]
- Woocommerce Large Variations Shows Out of Stock Items [closed]
- Why does theme need woocommerce to show images / content on front page?
- How to add image for custom taxonomy
- how do I solve Installation failed: There has been a critical error on your website
- WooCommerce product prices not showing up correctly [closed]
- woocommerce show cities state as dropdown list
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- manage_{taxonomy}_custom_column not working
- I want to set a different banner for each product in the woocommerce plugin on my wordpress site
- How to add product thumbnail on orders list on backend?
- add_meta_box showing blank screen in my page
- How to create an Info Box on WordPress [closed]
- I want create woocommerec match products columns
- How to make content as required in custom post type?
- Free multi dealer rental cars (sign up) [closed]
- What are Seeds? [closed]