Search Result URL contains accents (é è à) and result error 404
-
Hi everyone,
Here’s my issue. I have this multi-language website I’m working on and I’ve been trying to add a search button on top to browse around the products.
Here’s the button code:
<form role="search" method="get" class="woocommerce-product-search" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <label class="screen-reader-text" for="woocommerce-product-search-field"><?php _e( 'Search for:', 'woocommerce' ); ?></label> <input class="trend-search-input" type="search" id="woocommerce-product-search-field" placeholder="<?php echo esc_attr_x( 'Search Products…', 'placeholder', 'woocommerce' ); ?>" value="<?php echo get_search_query(); ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label', 'woocommerce' ); ?>" /> <input class="trend-search-submit" type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>" /> <input type="hidden" name="post_type" value="product" /> <input type="hidden" name="lang" value="<?php echo ICL_LANGUAGE_CODE; ?>"/> <span class="trend-icon-search"></span> </form>
Now the search works fine, but whenever I type a keyword containing é à è or any other characters with an accent, I end up with a 404 error because the URL includes the accent.
ex. https://www.domain.com/?s=élite&post_type=product&lang=fr
I’ve been trying to fix this using the sanitize and remove_accents functions but it’s not working..
Any idea how I can modify the form so the URL doesn’t include the accents? (like this: https://www.domain.com/?s=elite&post_type=product&lang=fr)
Thanks
- The topic ‘Search Result URL contains accents (é è à) and result error 404’ is closed to new replies.