Here i am explaining perfectly. I have created a custom search with category in woocommerce. It was working fine but has an issue. I am having a product which has two category. 1. Women 2. Accessory.
When searching i make a search with in accessory category "accessory" (domain.com/?s=&post_type=product&product_cat=accessories)it shows the product in the search result. But when i click over the product and go to details page When i check the url it was showing (domain.com/shop/women/suede-heeled-shoes/)
What i am trying to get is if my search is for "accessory" category then it needs to show accessory in URL example (shop/accessory/suede-heeled-shoes/). Instead of getting other category title in url getting current search query. If my search is accessory the the details url also like this (shop/accessory/suede-heeled-shoes/) instead of (shop/women/suede-heeled-shoes/) . Thank you.