Forum Replies Created

Viewing 2 Topics - 1 through 2 (of 2 total)
Author Posts
March 3, 2014 at 8:21 pm in reply to: Post Not Assigning to Category 16110
Rogier Rogier

Hi Team,

How does it work if I want to have it work with the Product Categories from WooCommerce? I have tried, but it only takes my child category and doesn’t automatically add the parent category.

I have tried the following:

function wpufe_set_post_category( $post_id ) {
if ( isset( $_POST[‘product_cat’] ) ) {
$categories = $_POST[‘product_cat’];

$hierarchical = array_map( ‘trim’, array_map( ‘strip_tags’, explode( ‘,’, $categories ) ) );
wp_set_object_terms( $post_id, $hierarchical, ‘product_cat’ );
}

}

add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_set_post_category’ );
add_action( ‘wpuf_edit_post_after_update’, ‘wpufe_set_post_category’ );

But as said this doesn’t work.

Thanks in advanced for the support.

Best regards,

Rogier

March 3, 2014 at 3:54 pm in reply to: Parent Category Toggler 16106
Rogier Rogier

I am trying to get it to work for product_cat for woocommerce, but for some reason have not able to get it to work. Did somebody try if for categories used in Woocommerce? If so how?

Thanks in advanced!

Viewing 2 Topics - 1 through 2 (of 2 total)