elementor search template posts widget and Algolia
-
Hi dear plugin Support
I want search over my posts and a custom post type named faq in my wordpress website. I created a search template with elementor pro and I have put the posts widget with query set to current query.the problem is Algolia plugin (WP Search with Algolia by WebDevStudios) does not support pagination on posts widget. and it shows 404 page. how can I solve this issue?
The page I need help with: [log in to see the link]
-
Have you confirmed that the issue goes away when not having the Algolia integration included? Assuming you’re using the “use with native search template” setting, it should be overall working, as that setting makes use of the
pre_get_postshook and tells the query to fetch specific posts based on Algolia’s determination of most appropriate items. All of the rest of the query process would still be WordPress dictated.in response to “Have you confirmed that the issue goes away when not having the Algolia integration included?” I must say yes. when I select the option “Do not use Algolia” the search pagination works properly. I also tested when Elementor template is not applied to the search result and I must say problem still exist in that case as well. at the moment I select the option “Do not use Algolia”. but I need to solve this issue. any recommendation to troubleshoot this issue?
Is it using the
?s=airbnb&post_type%5B0%5D=post&post_type%5B1%5D=faqstyle query string in all cases? What about in each variation having it just stick to?s=airbnbwithout the post type parts? That could be potentially throwing some oddities at things, and Algolia would still be handling the returned results.I have the same issue with a standard query “/?s=test” in a custom theme. I do the Pagination like that:
echo paginate_links(array( 'base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))), 'current' => max(1, $paged), 'show_all' => false, 'type' => 'list', 'end_size' => 2, 'mid_size' => 1, 'prev_next' => true, 'prev_text' => sprintf('<i></i> %1$s', __('« Vorherige Artikel', 'text-domain')), 'next_text' => sprintf('%1$s <i></i>', __('Weitere Artikel »', 'text-domain')), 'add_args' => false, 'add_fragment' => '', ));Based on the $wp_query->found_posts the number of pages should be right, but after some pages I get 404 errors.
As the site is in development mode, we don’t have a public URL.
@reti97 Are you creating this custom theme using your own custom WP_Query call? or is it the main query that WordPress would be making?
I’m using the main query in search.php with the setting: ” Use Algolia with the native WordPress search template”
And to confirm you don’t get that issue when you disable the Algolia integration? They just all work until there’s no more pages? What if you use some other pagination functions instead of this one?
I don’t get the problem as soon as the Algolia Integration is disabled. Exactly, to me, it seems the Plugin returns a higher number of Results then there actually are.
I’ve got the same issue when using the default pagination function.
I wonder if you have some other things tapping in to the query process and potentially affecting thing unintentionally.
Here’s the callback that we use for the native search integration:
https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.8.1/includes/class-algolia-search.php
Things of note:
- We utilize
get_option( 'posts_per_page' ),on line 137, so it should be matching up with the posts per page setting. Possible you’ve configured search to use a different posts per page, for which we’d want to filter thealgolia_search_paramsfilter on line 134 to match - We do seem to modify the posts per page parameter, but it matches up with the value mentioned in bullet point 1 above. You can see this on line 179
- We set the
post__invalue based on the returned results from Algolia. This can be seen on line 194
So something is going on, but the question is what and why.
@zeevousite Did you ever get this figured out?
I had a similar issue with Beaver Builder + FacetWP. It turns out the culprit was FacetWP and I needed to disable it. But I couldn’t simply do it because it was being using across the whole site for different purposes. So I used this code snippet below in the functions.php to disable FacetWP only when searching for content:
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( $query->is_search() && $query->is_main_query() ) {
$is_main_query = false;
}
return $is_main_query;
}, 5, 2 );So maybe the issue is not with Elementor and, if so, Elementor is probably messing with the WP Main Query and you should check how to disable this through Elementor hooks.
@munizleo Just to confirm with this part:
So maybe the issue is not with Elementor and, if so, Elementor is probably messing with the WP Main Query and you should check how to disable this through Elementor hooks.
Were you suggesting that we with WP Search with Algolia look into potentially doing something with that? or was that for the original thread starter?
@tw2113 It was for the original message.
Many different plugins mess up with the main query. In my case, I was thinking of Beaver Builder, but it was actually FacetWP and I only learned that when disabling FacetWP for testing. Without it, WP Search with Algolia worked well. So I found a way to disable it only for the search page by using theis_search()method.
I know this thread has already 3 months and the problem is probably already fixed by now. But, for anyone facing similar issues, it’s worth trying to disable some plugins that potentially change the WP main query behavior one by one to see if WP Search with Algolia works as expected.
Then, when finding the culprit, develop a way to bypass it for the search page withif ( is_search() && is_main_query() )or
if ( $query->is_search() && $query->is_main_query() )considering
$queryis the WP_Query object instance.Gotcha, and just making sure.
We try to help with as many cases as possible, but sometimes situations are too insurmountable for us to handle all of them.
Thanks.
- We utilize
The topic ‘elementor search template posts widget and Algolia’ is closed to new replies.