• Resolved John Smith

    (@zeevousite)


    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]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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_posts hook 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.

    Thread Starter John Smith

    (@zeevousite)

    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?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Is it using the ?s=airbnb&post_type%5B0%5D=post&post_type%5B1%5D=faq style query string in all cases? What about in each variation having it just stick to ?s=airbnb without 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', __('&laquo; Vorherige Artikel', 'text-domain')),
    					'next_text' => sprintf('%1$s <i></i>', __('Weitere Artikel &raquo;', '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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @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”

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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:

    1. 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 the algolia_search_params filter on line 134 to match
    2. 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
    3. We set the post__in value 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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @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 the is_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 with

    if ( is_search() && is_main_query() ) 

    or

    if ( $query->is_search() && $query->is_main_query() ) 

    considering $query is the WP_Query object instance.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.