Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 A way to get the query object from Timber::get_posts() #2605

Closed
piotrkulpinski opened this issue Jul 5, 2022 · 2 comments
Closed

v2.0 A way to get the query object from Timber::get_posts() #2605

piotrkulpinski opened this issue Jul 5, 2022 · 2 comments

Comments

@piotrkulpinski
Copy link

Is your feature request related to a problem? Please describe.

Back in the v1 there was a way to get the currently running query object via posts.get_query() function. I've noticed that was removed from the new version without any notice in the upgrade guide. Is there any alternative for that in the v2.0?

Describe the solution you’d like

I'd love to be able to grab the current query from the posts object with posts.query just like we can with posts.pagination.

Describe alternatives you’ve considered

I've tried grabbing the $wp_query via custom Twig function but it only works if you're using the default archive query (not a custom one).

Additional context

I'd like to build a custom pagination utilising infinite loading and to do that I need to be able to pass the current query_vars as I'm reusing the same pagination component in multiple places so the scripts must know what the current query actually is.

@gchtr
Copy link
Member

gchtr commented Jul 20, 2022

Hey @piotrkulpinski, thanks for this issue.

I've noticed that was removed from the new version without any notice in the upgrade guide. Is there any alternative for that in the v2.0?

We simply missed that for 2.0 😅. I added a pull request in #2613 that should fix this. To match the new method naming conventions for getter functions, we’ll probably rename it from get_query() to query(). You’ll get a deprecation notice if you’ll use get_query().

@gchtr
Copy link
Member

gchtr commented Jul 26, 2022

Resolved by #2613. This will be in the next release.

@gchtr gchtr closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants