• Hello
    Is it possible to ignore the (space) between words and numbers when searching a web site and to show both modes (for example: 100 uf & 100uf) and show results ?
    Currently, no results are shown for phrase (100uf) Only for results (100 uf) are displayed.
    We have many examples of this. We want to show in general the search results by (non-interval phrase) and (interval phrase) for all the values in the search box.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Yes, it is possible. Please use following code snippet

    add_filter( 'aws_search_terms', 'aws_search_terms' );
    function aws_search_terms( $terms ) {
        $new_terms = array();
        if ( $terms ) {
            foreach( $terms as $term ) {
                if ( preg_match( "/[\d]+/i", $term ) ) {
                    if ( preg_match( "/\b([^\d\W]+)([\d]+)\b/i", $term, $matches ) || preg_match( "/\b([\d]+)([^\d\W]+)\b/i", $term, $matches ) ) {
                        if ( strlen( $matches[1] ) > 1 ) {
                            $new_terms[] = $matches[1];
                        }
                        if ( strlen( $matches[2] ) > 1 ) {
                            $new_terms[] = $matches[2];
                        }
                    }
                }
            }
            if ( ! empty( $new_terms ) ) {
                $terms = array_merge( $terms, $new_terms );
            }
        }
        return $terms;
    }

    You need to add it somewhere outside plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Also after adding this code you will need to go to the plugin settings page and click ‘Clear cache’ button.

    Thread Starter frezvani

    (@frezvani)

    It’s work. thank you very much.

    Thread Starter frezvani

    (@frezvani)

    I’m sorry, When we add this code to the function.php file, the search problem is solved with a space, but the next problem is that as a result of the search, it does not display more than 100 results!

    Plugin Author ILLID

    (@mihail-barinov)

    Please use following code snippet

    add_filter('aws_page_results','aws_page_results');
    function aws_page_results( $num ) {
        return 999;
    }
    Thread Starter frezvani

    (@frezvani)

    Thank you very much. this code snippet work correctly, but site’s search in very slowly. Can you guide me in this regard?
    also in my site, I use from WCPT plugin (https://wcproducttable.com/) that wrote on the plugin’s website that the plugin is compatible with the “Advanced woo search” plugin. but because of the problem I mentioned at the beginning, I can’nt use from WCPT plugin’s search and I use from “Advanced woo search”. The search for the AAA plugin worked properly. In addition to the problem, the distance between the words and its speed was also very high. Can you guide me in this regard as well?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘searching with and without spaces’ is closed to new replies.