0

I am using SSHOP theme for my woocommerce store. when i search anything from home page search url works fine and following search permalink shows.

https://techcart.pk/?s=abc

but when i search when from product page or category page search result did not find anything and following permalink shows.

https://techcart.pk/product/8mm-led-10pcs/?s=abc

i want to rewrite the above permalink to be shown as https://techcart.pk/?s=abc

please help

1 Answer 1

0

Header <form> don't have action="" attribute. So basically what form do, when you search, is append s=keyWord in current url, that is why you have url like this https://techcart.pk/product/8mm-led-10pcs/?s=abc. What you need to to is to add action="" in <form>. You can inspect element in sidebar search field and you can see this markup:

<form role="search" method="get" action="https://techcart.pk/">

So basically you need to do the same on header search. Just replace action URL to be dynamically, like this:

<form role="search" method="get" action="<?php echo esc_url( home_url() ); ?>">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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