Search results page not found when hitting return or clicking the magnifying

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search results page not found when hitting return or clicking the magnifying

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #36178
    robratliff85
    robratliff85
    Participant

    I’m having 2 issues. One, we have many products that start with X- for example, X-400, X-600M, I want the customer to get the same search results if they type in x400 or x-400 but the results are different. What I really want is for x400 to delver the same results as the x-400 search. I’ve tried adding synonyms like x400 is the same as x-400, but the synonyms don’t seem to do anything. Even after I added the synonyms and rebuilt the index, I get different results when I search x400 than I do when I search x-400.

    Also, I followed the directions for the search results page to show the live results, but all I get is page not found when I click the magnifying glass or hit enter. If I let the results load on the search results page using the search field, that seems to work fine but when I click enter or on the magnifying glass I just get taken to a page not found error page. This happens when I search on the search results page, or on another page.

    Here is the link to my search results page: http://kelvinf1.sg-host.com/search-results-page/

    #36185
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Typing “x-400” and “x400” may yield different results, even if you have synonyms enabled – as there is still a possibility for fuzzy/partial matches, where the synonyms does not apply.

    There are two ways you can address this. Either by using the keywords exception feature (simply put the dash there). If that does not work, there is a simple programmatical way too.
    The programmatical way is probably much better, as it applies to the “raw” prhase, and has a much higher chance of actually working.

    I tried to access the actual core wordpress results page on your website, but when I try to go there, nothing is printed: http://kelvinf1.sg-host.com/?s=
    If you simply create a custom page, that will not become the results page, wordpress does not work like that. There is a results page handler programmed to your theme, and wordpress triggers that layout whenever the “s” query argument is detected.
    If you wish to use that custom page as the “fake” results page, it may still be possible. Try setting the results page redirection to this custom URL:
    search-results-page/?asp_s={phrase}

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #36193
    robratliff85
    robratliff85
    Participant

    Is there a way to force x400 to look for x-400 and x600 to search for x-600 etc. The reason is that removing the – only caused the x-400 to now search for x400 and x400 is the keyword not working properly. But if I can force x400 to search for x-400 the the search will deliver the right results.

    #36194
    robratliff85
    robratliff85
    Participant

    Also, thank you for the search results page fix. Now I’m wondering if we can make the results window taller? It’s only tall enough to show about 4 results.

    #36195
    robratliff85
    robratliff85
    Participant

    One other thing you could help with. When you search for something on the search page once it’s already loaded, the results come up blank, meaning they are there and if you hover over and click on the blank space it will take you to one of the search results pages, but you just can’t see the results. Try searching for something on the search results page, but don’t hit the return key.

    #36196
    robratliff85
    robratliff85
    Participant

    The top menu doesn’t fit correctly for the following 2 pages, but only when ajax pro search is activated. Once I deactivate ajax search pro, the page looks correct. If you give me your email, I’ll set you up with a username and password.

    http://kelvinf1.sg-host.com/level-monitoring/float-sensors/
    http://kelvinf1.sg-host.com/level-monitoring/pressure-sensors/

    #36199
    robratliff85
    robratliff85
    Participant

    Here’s what I’ve tried using the code you sent, but it still treats x400 like searching for x400
    /* Replace Keywords */

    add_filter( ‘asp_query_args’, ‘asp_replace_search_keywords’, 10, 2 );
    function asp_replace_search_keywords( $args, $id ) {
    /**
    * Add as many words as you want. On the left side place the
    * word or words separated by comma to replace.
    * To the right side, place the single word to replace it with.
    */
    $replace = array(
    ‘x400’ => ‘x-400’, // Replace ‘word1’ with ‘word2’
    ‘x600m, x-600-m’ => ‘x-600m’, // Replace ‘word3’ and ‘word4’ with ‘word5’
    );

    // —————————————-
    // Do not change anything below this line
    // —————————————-
    foreach ( $replace as $k => $w ) {
    $kr = explode(‘,’, $k);
    foreach ($kr as $krk => &$krv) {
    $krv = trim($krv);
    if ( $krv == ” ) {
    unset($kr[$krk]);
    } else {
    $krv = ‘/\b’ . $krv . ‘\b/u’;
    }
    }
    if ( count($krv) > 0 ) {
    $args[‘s’] = preg_replace($kr, $w, $args[‘s’]);
    }
    }
    return $args;
    }

    #36204
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    That custom code should do the trick, just make sure the dash is not include in the keyword exceptions list, that will negate the effects of it.

    If that does not work, try this variation instead:

    add_filter( 'asp_search_phrase_before_cleaning', 'asp_replace_search_keywords', 10, 1 );
    function asp_replace_search_keywords( $s ) {
    
      $replace = array(
        'x400' => 'x-400',       
        'x600m, x-600-m' => 'x-600m'
      );
    
      // ----------------------------------------
      // Do not change anything below this line
      // ----------------------------------------
      foreach ( $replace as $k => $w ) {
        $kr = explode(',', $k);
        foreach ($kr as $krk => &$krv) {
          $krv = trim($krv);
          if ( $krv == '' ) {
            unset($kr[$krk]);
          } else {
            $krv = '/\b' . $krv . '\b/u';
          }
        }
        if ( count($krv) > 0 ) {
          $s = preg_replace($kr, $w, $s);
        }
      }
      return $s;
    }

    The reason why nothing is happening on the results page is, beacause you have the results page live loader enabled, make sure to turn it OFF, that feature is used for a functional core results page.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.