SOLVED: Can the query loop be filtered using an ACF relationship field?

Hi guys,
i’m trying to filter the query loop using an ACF relationship field.
Can that be done with the Meta query field?

i have 2 CPT country and city with a relationship field linking the cities to the country.
When i’m on the city page i can display the country through dynamic data.
What i’m trying to do is make a template that displays the cities linked to the country using the query loop when i’m on the country page.

Many thanks for your help.

Did you solve this? I am trying to do similar.

Hi pazza,
Yes, in Bricks 1.4 they have added the option to use an ACF Relationship field in the query loop.

1 Like

Can you share some screen shots to get the idea or a video

Yeah - that would be awesome - I just can’t get it sorted.

It’s in the query type dropdown. It was right in front of me but took me some time to find.

I tried that. Didn’t work for me. I’ll try again.

OK - thanks I did get this going. I’m not sure what I did wrong last time but I did the same this time and it worked.

One question - how are you styling all the individual related post fields? There is only the dynamic field which pulls in the data but I would like to style each element. e.g. Posters Name, Related Post Comment, Image.

Are you wrapping these in custom code e.g DIVs?

Here’s a video where I walk through how I added styling and setup the entire review section. Hope it’s helpful :slightly_smiling_face:.

Thank you so much. I watched the follow up video to this one you linked to which explained the relationship should be made with posts type and then the post type. I can’t tell you how much I appreciate you sharing this!

Actually. I’ve got it looping but how do I limit it to the posts related to this specific post?

The screenshot shows you the posts and relationship but then the related posts shows on all my posts. But I just want to show the posts that are related to the post that I’m on? If that makes sense. I can’t see any other way to filter it to only related posts.

I don’t know how the relationship works with ACF but with Meta Box it’s very easy. What you have in the screenshot is not using relationship but you are showing all “Tip Contributions” posts. In the “Type” dropdown, see if you can select something with “relationships” instead.

This is how it works in Meta Box. I created a follow-up video because I didn’t see it right away :slightly_smiling_face:.

Thanks. I rewatched your video (here for anyone else is wondering 15 Configure Bricks Query Loop for Meta Box Relationships (Follow-up to video #14) - YouTube).

It is the same as yours i.e. ACF is same as Metabox, and it is working. It’s just only returning one result, not really looping, so I just need to figure that out next. Thanks for your help. Really appreciate it.

1 Like

Hilarious. Figured it out. I had my relationships backwards. e.g. was connecting the main page e.g. Author the related posts e.g. Books. So if you look at the book you get the author rather than connecting the books to the author.

Need more coffee…or less…

But, couldn’t have done it without your helpful videos. Thanks.

@pazza How do you achieve relationships with just Bricks and ACF? It’s not an option for me under Type.

I only have “post, terms, user”.

If you make one ACF relationship field, it will appear in type.
Also works for repeater and flexible fields.

Thanks for the tip, but I still can’t seem to get it to populate the query loop repeater.

This is what I have setup:

  1. Custom Post Type (Products)
  • within this CPT I have a relational field called “Type”
  1. Custom Post Type (Product Type)

  2. I’ve set the Type in the products

In the builder Type doesn’t show up in the query loop to repeat. Not sure what step I missed. Trying to add the Type in the dynamic field beneath the type field doesn’t show in the ACF options.

ACF Relation Field output does not work :roll_eyes: No matter how many times I’ve tried to set them up, there are no such fields when setting up a query. There is only ACF Repeater Field.

1 Like

Dp you know how to filter reviews in the loop? Once I add the relationship field query, there are no options to filter by meta query. Say I wanted to only pull in the review that contained a certain word. any ideas?

You can use a shared taxonomy based on the post’s taxonomy, or create an ACF relationship’s field specific to that post type. That’s how we’ve done it.