Plugin Author
ILLID
(@mihail-barinov)
Hi,
Looks like I found the reason for this issue. I will fix it in the next plugin version.
If you don’t want to wait – you can fix it right now by making some changes in the plugins source code. Please open file advanced-woo-search/includes/modules/class-aws-facetwp.php, find lines
$search_res = AWS_Search_Page::factory()->search( $obj->query, $obj->query_args['posts_per_page'], $obj->query_args['paged'] );
and replace it with
global $wp_query;
$posts_per_page = $obj && $obj->query_args && isset( $obj->query_args['posts_per_page'] ) ? $obj->query_args['posts_per_page'] : $wp_query->query_vars['posts_per_page'];
$paged = $obj && $obj->query_args && isset( $obj->query_args['paged'] ) ? $obj->query_args['paged'] : $wp_query->query_vars['paged'];
$search_res = AWS_Search_Page::factory()->search( $obj->query, $posts_per_page, $paged );
Regards
@mihail-barinov, The number of displayed items is now working correctly, thank you very much. But the problem with pagination, unfortunately remained.
-
This reply was modified 3 years, 1 month ago by
dipokemon.
-
This reply was modified 3 years, 1 month ago by
dipokemon.
@mihail-barinov I ran into this same problem but found that all pages were returning page 1’s results. With FacetWP’s AJAX filtering you need to account for $_GET['_paged'] .
I changed the third line of your solution to this:
if( isset( $_GET['_paged'] ) ){
$paged = intval( $_GET['_paged'] );
} else {
$paged = $obj && $obj->query_args && isset( $obj->query_args['paged'] ) ? $obj->query_args['paged'] : $wp_query->query_vars['paged'];
}
This means the full code becomes the following:
global $wp_query;
$posts_per_page = $obj && $obj->query_args && isset( $obj->query_args['posts_per_page'] ) ? $obj->query_args['posts_per_page'] : $wp_query->query_vars['posts_per_page'];
if( isset( $_GET['_paged'] ) ){
$paged = intval( $_GET['_paged'] );
} else {
$paged = $obj && $obj->query_args && isset( $obj->query_args['paged'] ) ? $obj->query_args['paged'] : $wp_query->query_vars['paged'];
}
$search_res = AWS_Search_Page::factory()->search( $obj->query, $posts_per_page, $paged );
@d2roth, Unfortunately it didn’t help. But I noticed that my FacetWP filters and pagination don’t work when using Query = Latest Products, I haven’t been able to find a solution to this problem yet, can you advise something.
The question is a little off topic.
@dipokemon Are you using Elementor Pro?
@d2roth Yes, I am using elementor pro
For reference I am testing with the following plugin versions:
- Elementor: 3.12.2
- Elementor Pro: 3.12.2
- FacetWP: 4.1.8
- FacetWP – Elementor: 1.7
- Advanced Woo Search PRO: 2.77
@dipokemon I found the previous solution didn’t fix the full issue. It seems like the pagination parameters are stored in $obj->ajax_params. Inside /wp-content/plugins/advanced-woo-search-pro/includes/modules/class-aws-facetwp.php about line 66 I have:
$paged = $obj && $obj->query_args && isset( $obj->query_args['paged'] ) ? $obj->query_args['paged'] : $wp_query->query_vars['paged'];
Changing that to the following (query_args to ajax_params) is fixing prev/next pagination since $obj->query_args is null in my tests:
$paged = $obj && $obj->ajax_params && isset( $obj->ajax_params['paged'] ) ? $obj->ajax_params['paged'] : $wp_query->query_vars['paged'];
Does that change anything for you?
Also, Facet’s filters don’t change the resulting page items when using AWS. It seems to spit out the full product information without the filtering being applied. Are you seeing similar results?
@d2roth Sorry for the long answer. Instead of the usual pagination that is used in the elementor, I began to use the pagination from FacetWP and everything works as it should.
Plugin Author
ILLID
(@mihail-barinov)
Should be fixed starting from plugin version 2.79.
@dipokemon what versions are you using? FacetWP’s pagination doesn’t change pages when we have done a search and filter even using Advanced Woo Search 2.79.