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 has 7 replies, 2 voices, and was last updated 4 years, 4 months ago by
Ernest Marcinko.
-
AuthorPosts
-
January 4, 2022 at 8:00 pm #36178
robratliff85
ParticipantI’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/
January 5, 2022 at 2:21 pm #36185Ernest Marcinko
KeymasterHi,
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}January 5, 2022 at 5:01 pm #36193robratliff85
ParticipantIs 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.
January 5, 2022 at 5:07 pm #36194robratliff85
ParticipantAlso, 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.
January 5, 2022 at 5:16 pm #36195robratliff85
ParticipantOne 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.
January 5, 2022 at 5:54 pm #36196robratliff85
ParticipantThe 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/January 6, 2022 at 12:18 am #36199robratliff85
ParticipantHere’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;
}January 6, 2022 at 1:30 pm #36204Ernest Marcinko
KeymasterHi,
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.
-
AuthorPosts
- You must be logged in to reply to this topic.