0

Let's say I have category Foods and it has a child: Chicken.

By default, the URL for Chicken category will be like: yoursite.com/product-category/foods/chicken.

Is there a way to make it yoursite.com/product-category/chicken? I want to keep the parent-child relation so I can query all Foods and list all child-categories of Foods.

1

Try something like this in your functions.php:

function ran_remove_parent_category_from_url( $args ) {
    $args['rewrite']['hierarchical'] = false;
    return $args;
}

add_filter( 'woocommerce_taxonomy_args_product_cat', 'ran_remove_parent_category_from_url' );
  • Nice didn't expect the solution to be this simple. Thanks – hrsetyono Oct 13 '17 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.