php – how can change search value in woocommerce

Question

I have an input search field that I made custom. When this input value is entered, I want it to search for the products on the page, but I could not.

In short, when I enter leather in the input field, I want it to redirect to such a page.

localhost/example/?s=leather&post_type=product

Following my code:

HTML

<input type="text" name="s" id="keyword" onkeyup="fetch()" placeholder="Search.." >

functions.php

echo ' 
<form role="search" method="get" class="search-form" action=" '.home_url( "https://wordpress.stackexchange.com/" ).' ">
 <div class="search-btn">
   <a href="#">View All</a>
 </div>
</form>
    ';

Thank you advance..

0
Ferhat 2 months 2021-10-02T03:58:52-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse