-
seemly
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.
-
David
Hi there,
can i see the function you’re using to add the query params to URL ?
-
seemly
Sure thing.
Apologies for the formatting, Github Gist just flat-out ignores me.
https://gist.github.com/seemly/8cef127b3b0e7959709262c1a8da0b89
-
David
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
-
seemly
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.
-
David
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:
-
seemly
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? -
seemly
The default
$args
array for that Generate Blocks Query Loop instance when dumped fromgenerateblocks_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? -
seemly
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 🙂
-
seemly
BOOM!
That worked!
I should have considered that, really.
Thanks so much for your help, Tom!
-
Glad I could help! 🙂
- You must be logged in to reply to this topic.