Hi everyones,
I try to find a way to access the “$_query” made on a get_field() Relationalship field.
I use ACF Relationalship field to display a paginated listing of posts on a CPT page.
I think i’ll be able to paginated the listing with the acf/fields/relationship/query hooks by adding posts_per_page param value to the acf query.
But in my page i want also to display a form to filter the listings based on taxonomies.
I already have made this filter form based on the wp main query for my archive page.
It uses main query, to relaunch the same search except the posts_per_page param at -1, to retrieve all the posts.
If i can access the acf “$_query” made, on a Relationship field, i’ll be able to re-use the code i write for my archive filter, by passing the acf “$_query” instead of the main query.
Any ideas ?
Thanks for your advises and your time!
acf/fields/relationship/query is only run in the admin when populating choices of the relationship field.
To change the posts_per_page argument you would do that in the same place where you are applying the other filters.
Hi John,
And thanks for your answer. I just came back from my holidays.
If i understand you well, the query made by acf to get the posts that match the relationship field, uses the posts_per_page define in the wp admin panel ?
Anyway, my goal was to display a paginated list of posts.
List which users can filters with taxonomies.
And to achieve this, do not use another query. i.e. use only the query already made and modify this query with a pre_get_posts hook like.
I manage to do so, in my archive page with the main_query and the pre_get_posts hook.
But i don’t think it’s possible to achieve this, on my relationship based posts list, without made an additional custom query