Plugin Author
ILLID
(@mihail-barinov)
Hello,
Please try to use following code snippet
add_action( 'template_redirect', 'tp_redirects', 1 );
function tp_redirects() {
if ( isset( $_GET['type_aws'] ) && ! isset( $_GET['filters'] ) ) {
$prev_url = $_SERVER['HTTP_REFERER'];
if ( $prev_url ) {
$parse_url = parse_url( $prev_url );
if ( isset( $parse_url['query'] ) && $parse_url['query'] ) {
parse_str( $parse_url['query'], $prev_url_queries );
if ( isset( $prev_url_queries['filters'] ) ) {
$current_url = $_SERVER["REQUEST_URI"] . '&filters=' . $prev_url_queries['filters'];
wp_redirect( $current_url, 301 );
exit();
}
}
}
}
}
You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
This code will add BeRocket filter parameters to URL when using plugin search on a page where these filters were already applied.
Regards
Thread Starter
ilythia
(@natureonemockups)
Hi there,
thanks for the code! I used Code Snippet to add it to my page but unfortunately nothing changed. :/
Best,
Nancy
Thread Starter
ilythia
(@natureonemockups)
Just found that there is a typo in:
$current_url = $_SERVER["REQUEST_URI"] . '&filters=' . $prev_url_queries['filters'];
URI = URL, I guess? But it’s still not working. 🙁
hi, post search filters don’t work for me. Always return 0 results
-
This reply was modified 5 years, 3 months ago by
marketwo.
-
This reply was modified 5 years, 3 months ago by
marketwo.
Plugin Author
ILLID
(@mihail-barinov)
@natureonemockups
No, there is no typo.
One more question – do you use BeRocket filter with ajax filtering? If so – please try to temporarily disable this ajax feature and test one more time with the code that I provided previously.
Regards
Thread Starter
ilythia
(@natureonemockups)
Without AJAX enabled it’s working! 🙂 But there is no way to make it work without disabling AJAX (due to faster loading), isn’t it?
Thanks so much for taking the time to look into that!
Plugin Author
ILLID
(@mihail-barinov)
Looks like I understand how to help you. You can still use AJAX filter but please go to the BeRocket settings page and inside SEO tab enable ‘Refresh URL when filtering’ option. This must solve the issue.
Thread Starter
ilythia
(@natureonemockups)
Now it works just perfectly! Thanks so much!