You can try the following code to check whether a category with a name exist of not
$search_category_name="T-shirts";
//This gets top layer terms only. This is done by setting parent to 0.
$parent_terms = get_terms('product_cat', array('orderby' => 'slug', 'hide_empty' => false));
foreach ($parent_terms as $pterm) {
//check whether the category_name exists
if ($search_category_name == $pterm->name) {
return true;
}
}
And for creating a new one you can refer to this link
Related Posts:
- Attach a Custom Post Type to a Woocommerc product as a variation or add-on [closed]
- Exclude a term of a taxonomy with a custom post type in a search
- How to solve suspected memory issue in custom WordPress loop?
- Query for posts from any post type but only add instock products
- WooCommerce – Show orders for a specific product ? [closed]
- Set meta_query only for specific post type
- get_terms won’t display product_cat or any other custom taxonomies when specified
- Woocommerce query specific product from specific category
- Problem adding column to WC Subscription [closed]
- Create custom post type on successful woocommerce order [closed]
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- How to display product subcategories into my custom post type single page
- Get post from custom post type order by two taxonomies
- changing meta value and meta key of price field
- Woocommerce search pagination not working
- WooCommerce Customer Role Delete Custom Post Type
- WooCommerce sort products by the actual product width(not the shipping width)
- Manage custom post type in woocommerce /my-account/ page
- Woocommerce custom field search in custom post type [closed]
- Modifying custom post type created by WooCommerce
- Hide a widget inside a div on specific type of post
- Allow add new post access to custom post but not wp post for some role
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Display Woocommerce Orders for specific author [closed]
- Sort posts in loop by the WooCommerce Membership of the author
- How to set up Custom Post Type archive page as Front page
- Copy order items with metadata between orders – Woocommerce
- Update Post Status On Woocommerce Payment Complete
- Get all post from a post type
- Custom Post Type to replace Woocommerce products – page not found error
- CPT as Product in WooCommerce
- Change permalink for custom_post_type using custom_post_meta (woocommerce)
- Blank search results on custom search
- Get Terms from Custom Taxonomy and Current Post
- Is it a connection or relationship between 2 custom post types?
- Custom Post type to Woocommerce Product type
- How to display related posts using the same taxonomy for custom types (WordPress, Pods, Woo)
- How to display custom field in product description?
- Add two custom product type
- Duplicate the “Orders” list on Admin Page
- What’s the best way to do this: inquiry/ticket system?
- Sudden 404 pages on product category archives
- WordPress shortcode to pull product post data
- ‘Simple’ Reservation System
- Change display of product price on product show page only
- edit.php all post not working
- How to show link to product in custom fields?
- add action save post type and update post meta woocommerce
- WooCommerce – Custom related product (Spareparts)
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- WooCommerce change
- WooThemes – Vendors / Bookings – Allow Vendors to manage resources
- Search in multiple specific post types
- woocommerce post_type conflict with existing post type
- Custom Taxonomy not working front side Woocommerce
- WooCommerce breadcrumb display custom posts instead of product data
- Custom Taxonomy is disabled on Edit page
- CPT or Custom Table for Repository of Serial Numbers
- Get Non-Paginated Index of Post in Paginated Query
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Custom Search Template for Custom Post Types
- WooCommerce – Complete Order when an action occurs
- How to manage a bookstore
- Issue On Listing Woocommerce Parent Tag List
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- Custom taxonomy not showing up when adding a new custom post type
- Including Custom Post Types in “Recent Posts” Widget
- WP cron: when to schedule a 1-time event
- Pre get posts for single post
- Custom Posttype Inheritance (and url structure)
- How to get custom metabox image field?
- Custom Post Types – Capability Type
- Rewrite permalinks for custom posttype and custom taxonomy
- Adding a date archive to Custom Post Type
- Automatic category for a Custom Post Type
- Get the post children count of a post
- Link images to post permalink – custom post types
- Recommended way to remove WP REST API returned data for custom post
- Rewrite WordPress URL to show CPT meta field data
- Set menu active state for custom posttype and category, given custom taxonomy term
- Custom Post Type Tag Capabilities Not Working
- Custom post type structure for posts with multiple child posts
- Hide parent categories when clicked, and show it’s childs
- Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy
- Multiple (two) category postings on the same page.
- Admin Column does not populate with data
- Custom taxonomy page returns 404
- Why does wp_update_post causes white screen?
- Targeting custom post type via functions.php doesn’t work
- Filter posts of custom post type by meta key in (List All Section)
- Custom post type meta box empty after save
- Custom post type rewrite slug translate?
- Simple Data picker meta box
- Custom post template doen’t have any
- Taxonomy Page Go to 404 pgae
- Custom taxonomy page template
- Custom post type pagination, single page issue
- Custom role can’t create permalink
- Radom post image/link based on custom taxonomy
- Remove custom meta boxes from custom post type