WooCommerce Categories & Products Page URLs same as magento URL

I am trying to achieve URL structure similar to Magento. I have just moved my website from Magento to WooCommerce, But Due to SEO Reasons, I wanted to keep the same URL Structure in WordPress/WooCommerce. I implemented a piece of code to achieve .html extension at the end of each product and product category page. But As of Now. Its only working for Products page But Category page is not showing .html extesion, So I need help. Please see the codes:

For Products Pages:

function wpse_178112_permastruct_html( $post_type, $args ) {
if ( $post_type === ‘product’ )
add_permastruct( $post_type, “{$args->rewrite[‘slug’]}/%$post_type%.html”, $args->rewrite );

add_action( ‘registered_post_type’, ‘wpse_178112_permastruct_html’, 10, 2 );

Its working perfectly for products pages

For Product Categories Pages:

function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) {
if ( $taxonomy === ‘product_cat’ )
add_permastruct( $taxonomy, “{$args[‘rewrite’][‘slug’]}/%$taxonomy%.html”, $args[‘rewrite’] );

add_action( ‘registered_taxonomy’, ‘wpse_178112_category_permastruct_html’, 10, 3 );

Not Working for Product Categories pages. It is still showing like http://domain.com/product-cat But I want it to show http://domain.com/product-cat.html

I tried all possible ways as per my knowledge to figure out the problem But I couldn’t do that.
Currently Product Pages URL is like: http://domain.com/product/product-category/product-name.html.
But I want it to show only Product category and product name ending with .html like this: http://domain.com/product-category/product-name.html
I changed Permalinks settings to remove “Product” word But not working. So Please assist to figure out this issue.

Read more here:: WooCommerce Categories & Products Page URLs same as magento URL

Leave a Reply

Your email address will not be published. Required fields are marked *