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
- All of my custom posttypes are 404’ing
- Display post lists in 2nd paragraph
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- How to enable specific plugin only based around shop manager role?
- What are wsm tables for?
- WordPress automatically removes line break
- Why required field not working in Country dropdown in WooCommerce –
- Woocommerce API HTTP Response 401
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- How to use WP-CLI / WC-CLI to bulk import 1000s of products (variable and simple)?
- wp_get_post_terms is difference obj model than the one in rest api response
- Add woocommerce variation images in gallery?
- woocommerce payment gateway callback not firing [closed]
- How to modify WCMP Rest API response?
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- WordPress Keeps Logging Out – What Tests Can I Run to Solve This?
- Woocommerce dependent plugin
- How to check current user before all actions and filters?
- how to add a button next to the wordpress view button?
- New databes tables with – WooCommerce – for developers [closed]
- How to send an automated email to the customers when product is added woocommerce
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- WooCommerce: Building a page with user input which is used to query order status and external API and return a result
- woocommerce product countdown not showing in variable product? [closed]
- Change commission_status paid when withdraw_status vendor is completed
- I want to disable Cash on delivery based on product tag in woocommerce Checkout Page [closed]
- Is there a way to create custom product templates based on category on WooCommerce?
- Woocommerce Deposit, then random payments until product paid in full [closed]
- How to toggle between two custom fields in WordPress woocommerce ‘WC Product Field Group’ plugin?
- custom payment gateway in woocommerce failed to connect to remote api server
- Classified ad website : which solutions to use? [closed]
- Programmatically Process Order through WooCommerce/Stripe Payment Gateway [closed]
- Replacing a plugin function with a custom renamed function doesn’t work
- CampaignMonitor for WooCommerce – Move subscribe button [closed]
- Multiple Billing forms in WooCommerce (one billing form per product)
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- 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
- Pre booking doesn’t work with custom bootstrap modul in woocommerce [closed]
- WooCommerce specifc variations for specific user role [closed]
- Save custom attributes of product in woocommerce
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Filtering WooCommerce Orders by Category
- Best place for short bio,image and button [closed]
- trying to get product category image in woo-coomerce
- How to add checkboxes for a woocommerce product? [closed]
- What are the specifics of WordPress development I need to know? [closed]
- Why am I getting ( WooCommerce Services could not be installed (Could not create directory.). ) error and how to solve it ?
- Product queue for my subscription box
- Want to Show Sub categories under Categories section using Woo Commerce [closed]
- WordPress shows error related to allow_url_fopen
- how to do login using woocommerce rest api From android
- Custom Pages for Woocommerce Product-Category Pages
- Woocommerce Minimum Price for a Composite Product to add in cart
- How to create a code editor for my plugin .?
- How to show only next post pagination link using wp_link_pages()
- creating a custom shop page display on archive woocommerce
- Finding the URL to be used to check if plugin is installed with a theme
- Js file is not adding using this code in functions.php
- wp_footer hook only working on homepage not in other pages
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- Woocommerce Shop page variation product button replace with add to cart button
- Plugin can not display in my custom theme
- How can I insert thousands of Woocommerce products by batch with PHP? [closed]
- WooCommerce search products between price range using WP_Query
- How to use get_template part in the plugin?
- Jquery NoConflict Problem
- Overriding Parent Theme… will cause plugins failure?
- WordPress premium theme development [duplicate]
- How to use add_submenu_page() for editors?
- How do I combine a theme with a plugin
- PHP Error When a plugin is active
- how to force tag page layout to use same as search layout?
- woocommerce with custom post type
- How can I show a different theme for admin users? WP 3.8+
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Exact Hook to payment methods
- Restrict content based on buy woocommerce product
- How to show the number of website visitors in my theme
- How to write “alt” tag in image for wordpress code?
- How to get a list of bundled products using wp_query in woocommerce
- Adding Static Image to WooCommerce Content-Single-Product template
- Hide a Menu Item on Login
- multiple language website navigation menu suggestion
- How to multiply a post to test internal search results?
- Use different single.php file based on condition
- Customizing Titles on the Fly with Code
- Add SideBar/Widgets Just Below the Post
- Add filter on html tags,attributes on specific function in wordpress
- Product count in archive page Title in WooCommerce [closed]