Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search box swapping
This topic contains 21 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year ago.
- AuthorPosts
- March 7, 2022 at 6:48 am #37051
Hello,
I have replaced the WooCommerce default search with Ajax Search Pro. The problem is that every other time the default search bar is displayed. If you would like to see the issue, please visit opars.com products pages.
I have cleared my browser, the website and the server caches several times!
Any resolution would be appreciated.
Kind regards,
MajidMarch 7, 2022 at 7:52 am #37055Hi Majid,
Thank you for the details!
I have tried a couple of products, but all seem to have the default search bar instead of ajax search pro. It does not seem like a cache issue, but I suspect the product pages may use different headers as the home/search page.
Best,
If you are using a theme builder of some sort, check the product page headers template, it is very likely different. If it was the same, te same output would be displayed on the home and product pages.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 8:03 am #37056Hi,
I am using Flatsome theme.
There is only one header for all pages.Any other idea, please?
Best,
MajidMarch 7, 2022 at 8:09 am #37057Have you replaced it manually in the theme editor, or using code or..?
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 8:12 am #37058Used ASP settings. Please see attached screenshot
Attachments:
You must be logged in to view attached files.March 7, 2022 at 8:34 am #37060That should work, unless there is some sort of a custom code or a different plugin overriding the search.
You can try a custom code to forcefully deregister the flatsome search shortcode, and replace it with ASP. Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
Best,function search_shortcode2($atts) { extract(shortcode_atts(array( 'size' => 'normal', 'style' => '', 'class' => '', 'visibility' => '' ), $atts)); $classes = array( 'searchform-wrapper' , 'ux-search-box', 'relative' ); if( $class ) $classes[] = $class; if( $visibility ) $classes[] = $visibility; if( $style ) $classes[] = 'form-'.$style; if( $size ) $classes[] = 'is-'.$size; $classes = implode(' ', $classes); ob_start(); echo '<div class="'. $classes. '">'; echo do_shortcode('[wd_asp id=1]'); echo '</div>'; $content = ob_get_contents(); ob_end_clean(); return $content; } remove_shortcode("search"); add_shortcode("search", "search_shortcode2");
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 8:46 am #37062Hi,
Thanks for the code, but still the default search bar is randomly displayed instead of ASP!
March 7, 2022 at 9:36 am #37064Can you please add temporary FTP and back-end access? I will debug the code to see what is happening. It is probably a theme/3rd partys code issue, but I will double check.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 9:45 am #37066You cannot access this content.March 7, 2022 at 2:00 pm #37075Thanks!
Looks like it was some sort of an issue with the theme registering the shortcode too early, and no other shortcodes could be registered at that time. Interestingly it only happened in some cases.
It seems like this variation to the code has resolved the issue:
// Replaces Flatsome searhbar with ASP function search_shortcode2($atts) { extract(shortcode_atts(array( 'size' => 'normal', 'style' => '', 'class' => '', 'visibility' => '' ), $atts)); $classes = array( 'searchform-wrapper' , 'ux-search-box', 'relative' ); if( $class ) $classes[] = $class; if( $visibility ) $classes[] = $visibility; if( $style ) $classes[] = 'form-'.$style; if( $size ) $classes[] = 'is-'.$size; $classes = implode(' ', $classes); ob_start(); echo '<div class="'. $classes. '">'; echo do_shortcode('[wd_asp id=1]'); echo '</div>'; $content = ob_get_contents(); ob_end_clean(); return $content; } remove_shortcode("search"); add_action( 'plugins_loaded', 'my_plugin_override1' ); function my_plugin_override1() { // your code here remove_shortcode("search"); add_shortcode("search", "search_shortcode2"); }
Although I still recommend investigating if you have any type of object cache active, to make sure the issue is not replicated.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 2:10 pm #37077Have you implemented the code?
On my side, nothing has changed and the issue still exists!March 7, 2022 at 2:24 pm #37079Yes. On my end everything seems to work.
This is definitely not an issue with the plugin (and very likely not an issue with the theme either), it is not possible for the same code to execute with the same parameters and have different outputs.
The same pageview is giving different outputs, and that is not possible – unless there something in the middle, which changes the output at will – like a cache plugin, CDN or something on the server side – check opcode cache, other type of opcache, memcached and similar modules.
I could only replicate this one time – on the first pageview the old search was there, on the second (and every pageview afterwards) the new search. Even when I edited the theme code to not show anything, it had no effect – so some sort of a cache on the server side is present.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2022 at 2:29 pm #37080I cleaned all caches on my computer and on the server, but still the same issue!
March 7, 2022 at 2:35 pm #37082Tried Gtmetrix using this link:
https://www.opars.com/shop/persian-book/pardahnishinan-i-%ca%bbahd-i-nas%cc%a3iri/
The same issue exists on its preview!
March 7, 2022 at 3:21 pm #37085Don’t worry, I will investigate this further in a minute, and let you know.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.