Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Query Loop Pagination Issues | Page Numbers do not update with custom filtering

  • I’m building a page using the GenerateBlocks Query Loop, and everything is working great.

    As a web developer, I’ve also added custom filtering functionality using the generateblocks_query_loop_args filter.

    While the filtering functionality works fine, and the Query Loop results update as expected, the pagination numbers do not reflect the correct number of paged results.

    Even when appending the Query Loop block query parameter to the query string, the Pagination numbering is not updated.

    Example query:
    ?query-73bd2471-page=1&cst&price_min=100000&price_max=600000&location=&property_type=cottage&listing_status=&order_by=

    Is this currently possible? If so, how?

    If not, can it be – even if it’s a case of adding a hidden input field with the ID of the Query Loop block instance?

    I have added real URLs and examples in the Private Information field.

  • Hi there,

    can i see the function you’re using to add the query params to URL ?

  • Sure thing.

    Apologies for the formatting, Github Gist just flat-out ignores me.

    https://gist.github.com/seemly/8cef127b3b0e7959709262c1a8da0b89

  • Might want to consider just appending your params to the end of the URL.
    See here for an example:

    https://generate.support/topic/query-loop-page-turner-does-not-return-to-top/#post-17997

  • I don’t think that will work (I just tried it, and it didn’t).

    That would mean I’d need to add a class to every dynamic page number link, which obviously isn’t very doable based on their dynamic nature.

  • What happens if your return your custom args using array_merge, and that way it won’t overwrite the query loop params. See here for an example:

    https://generate.support/topic/how-to-display-loop-query-that-contains-the-same-custom_field-value-as-the-curre/#post-17819

  • If I dump the $args array before I modify it, there are no references to the Query Loop block, so I’m going out on a limb and saying that this isn’t the problem.

  • Very strange, both the Loop and the Buttons use that filter, so the results should be the same.

    Out of curiosity, what happens if you ditch the $_GET conditions and just return the filters args with no input from the URL/browser?

  • The default $args array for that Generate Blocks Query Loop instance when dumped from generateblocks_query_loop_args is:

    array(5) {
      ["posts_per_page"]=>
      int(15)
      ["post_type"]=>
      string(8) "property"
      ["orderby"]=>
      string(5) "title"
      ["paged"]=>
      int(1)
      ["offset"]=>
      int(0)
    }
  • Is this before or after removing all of the $_GET conditions?

  • Based on your question:

    Out of curiosity, what happens if you ditch the $_GET conditions and just return the filters args with no input from the URL/browser?

    I just dumped the $args before any modifications.

    Without the modifications, no custom filtering happens (obviously), so the default Query Blocks pagination counts work.

  • Aha, found the issue.

    Our custom code is altering the query only when the property-search class name is found.

    The solution is to add that class to the pagination Button blocks as well: https://www.screencast.com/t/ZdcOYGDhG

    That way the query alteration will apply to those as well as the main query.

    This is something we should improve in the future, as doing this isn’t ideal. However, it should fix the issue as it is now.

    Let me know 🙂

  • BOOM!

    That worked!

    I should have considered that, really.

    Thanks so much for your help, Tom!

  • Glad I could help! 🙂

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