benjamin
(Benjamin Tracy)
January 11, 2024, 6:44pm
3
Query parameters are loop-type-specific, so I’m not sure that query parameters from the post loop type like exclude
are even supposed to work on an ACF relationship loop type (or a repeater loop type for that matter). I think the idea here is that an ACF relationship field is simply a list of posts, it’s not a query, which means you can’t filter it because it’s simply looping through the posts you’ve defined in the relationship field. Same idea with the repeater field, L&L isn’t querying data, it’s just looping through the information in your field. It is possible to sorta “convert” an ACF relationship loop into a post loop, at which point it actually is querying your posts and you’ll be able to use all the query parameters from the post loop type.
<Loop type=post post_type=post include="{Field acf_relationship_field_name}">
That being said, I’m not sure if the specific exclude
parameter would work because then you’d effectively be saying “loop through these specific posts, but also don’t loop through this same post I’ve already told you to loop through” which doesn’t work logically.
If include
doesn’t work, try id
:
<Loop post_type=post id="{Field acf_relationship_field_name}" exclude=24752>
I’ve asked Eliot whether we can make relationship loops natively accept query parameters from the post loop, so maybe that will get added in a future version.