Ah okay, that makes sense! I actually made a mistake in my previous code example (I was trying a couple of things and ended up mashing two ideas together) but I think one solution you should try is filtering your loop using the post loop’s query parameters. So you’d use the taxonomy
query parameter to only loop through posts that have that taxonomy applied and then the terms
parameter to further filter your loop to only posts that have your taxonomy term “active” applied to them. So something like this:
<Loop acf_relationship=client_projects taxonomy=stage terms=active>
That being said, while this solution would definitely work for a regular post loop (i.e. <Loop type=post>
), I’m actually not certain if the acf_relationship loop accepts the same query parameters as the regular post loop. If it doesn’t, then your first hypothesis about needing to nest some conditional logic inside your loop might actually be the right option here. If that’s the case, you’ll want to read up on what core conditions the If tag accepts and make sure your conditional logic fits that format. Something like this might work:
<Loop acf_relationship=client_projects>
<If check="{Taxonomy stage}{Term title}{/Taxonomy}" value=active>
<div class="row">
<div class="col-1"><Field acf_editor=project_pid /></div>
<div class="col-4"><Field acf_editor=project_name /></div>
<div class="col-2"><Taxonomy stage><Term title /></Taxonomy></div>
<div class="col-1"><Field acf_editor=project_start /></div>
<div class="col-1"><Field acf_editor=project_target /></div>
<div class="col-3"><Field acf_editor=project_next_step /></div>
</div>
</If>
</Loop>
I’m pretty certain that the second option here should work for you, but definitely give the first option a try since if the acf_relationship loop accepts regular post loop query parameters, that’d be more efficient. Note that this second option I’ve suggested would only work as-is if you only set one stage term per post, but I assume that’s the case in your example. Let me know which of these ends up working for you! If the second option ends up working for you, you could test whether it might be more efficient to Set
a variable for your Term title before your conditional statement and then Get
that variable both inside your If statement and inside your third div
.
Hope those ideas are enough to get this working for you, let me know if you have any other questions!