From 6577d8086bff3f2ccaf0ab238f826b1e0d0ee0fa Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Mon, 2 Jun 2014 14:48:52 -0300 Subject: [PATCH] fixed the product attachment urls when use n/%product_cat% as base url, closes #5159 --- includes/class-wc-post-types.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-post-types.php b/includes/class-wc-post-types.php index fa2cec29217..41d158dbeb2 100644 --- a/includes/class-wc-post-types.php +++ b/includes/class-wc-post-types.php @@ -209,7 +209,7 @@ class WC_Post_types { ); } } - + do_action( 'woocommerce_after_register_taxonomy' ); } } @@ -262,6 +262,10 @@ class WC_Post_types { ) ); + if ( preg_match( '/\/(.+)(\/%product_cat%)$/' , $product_permalink, $matches ) ) { + add_rewrite_rule( '^' . $matches[1] . '/.+?/[^/]+/([^/]+)/?$', 'index.php?attachment=$matches[1]', 'top' ); + } + register_post_type( "product_variation", apply_filters( 'woocommerce_register_post_type_product_variation', array(