Last active
May 25, 2022 13:27
-
-
Save runezero/e85b00aa5fe0c377bb1bd27c8a05f36c to your computer and use it in GitHub Desktop.
[Shop search redirect] Redirect the search bar to the shop page for product search #woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('get_search_form', 'adjust_search_form'); | |
| function adjust_search_form($html){ | |
| $home = get_home_url(); | |
| $shop = wc_get_page_permalink( 'shop' ); | |
| if($home == $shop){ | |
| $shop = $home .'/shop'; | |
| } | |
| $html = str_replace($home, $shop, $html); | |
| return $html; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment