Merge pull request #23638 from woocommerce/update/23632

woocommerce_product_post_type_link_parent_category_only filter
This commit is contained in:
Rodrigo Primo 2019-05-15 15:59:12 -03:00 committed by GitHub
commit 33ee11dd62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -216,7 +216,11 @@ function wc_product_post_type_link( $permalink, $post ) {
$ancestors = get_ancestors( $category_object->term_id, 'product_cat' );
foreach ( $ancestors as $ancestor ) {
$ancestor_object = get_term( $ancestor, 'product_cat' );
$product_cat = $ancestor_object->slug . '/' . $product_cat;
if ( apply_filters( 'woocommerce_product_post_type_link_parent_category_only', false ) ) {
$product_cat = $ancestor_object->slug;
} else {
$product_cat = $ancestor_object->slug . '/' . $product_cat;
}
}
}
} else {