Skip Navigation

[Resolved] Register Woocommerce Default Product Category with Types

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Shane 7 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#474029
function wep_add_product_cat_to_custom_post_type() {
	$args = array(
		'hierarchical'      => true
	);
    register_taxonomy( 'product_cat', 'slug_custom_post_type', $args );
}
add_action( 'init', 'wep_add_product_cat_to_custom_post_type' );

I am trying to:
With WooCommerce comes a default Product Category: 'product_cat' with Types Taxonomies its not recognized so i cant edit or assign this taxonomy to other custom post types. So i made this code to assign the default WooCommerce to a custom post type.

I visited this URL:
// https://codex.wordpress.org/Taxonomies
// https://codex.wordpress.org/Function_Reference/register_taxonomy

I expected to see:
Is there a better or easier solution to customize taxonomy's with Types?
// domain.com/wp-admin/admin.php?page=wpcf-ctt

Instead, I got:
/

#474047

Update for other users:
register_taxonomy() adds or overwrites taxonomy
get_taxonomy() with this you keep original taxonomy arguments

function wep_add_product_cat_to_custom_post_type() {
    $args = get_taxonomy( 'product_cat' );
    register_taxonomy( 'product_cat', array( 'product', 'another_cpt_slug' ), $args );
}
add_action( 'init', 'wep_add_product_cat_to_custom_post_type' );
#474110

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

Unfortunately Types wouldn't be able to edit the woocommerce product category as this is a specially made Taxonomy that doesn't follow the standard procedures.

Instead it is made specifically for woocommerce products so without some custom code this would be possible.

Such custom coding is out of the scope of our support forum.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.