ACF Relationship Loop inside of a Beaver Builder Post Loop

I am using a L&L ACF Relationship Loop shortcoded inside of a Beaver Builder post module.

The strangest thing is that it is only showing on the EVEN posts. Any idea what could be going on here? If I rearrange the posts, the relationship loop output stays on the 2nd, 4th, and 6th posts so it’s not tied to specific posts, but specific locations.

Here is the page. You can see the post layout with the L&L shortcode in it. And you can see the output at the bottom of those specific posts locations:

And here is the content of that L&L shortcode:
Screen Shot 2022-06-10 at 08.47.15

It’s really bizarre.

L&L is a fantastic tool for exactly what you’re doing.

Inside a BB Post Loop Custom Layout. I set a variable (called rel) to the name of the relationship field
[template id=51745 rel=dog-breed]

Then my template looks like
<Loop acf_relationship="{Get local=rel}">

Hope that helps.

Hi Richard, I’m not sure you took a look at my problem. If you read my problem again, it’s not working as intended on all posts. Only the even posts…

Looking at your response, I’m unsure how what you did is different than what I did though? Can you elaborate?

Hi Zack, this is really odd!
Could you try modifying your template to remove the “/” from the “{Field url /}” passed to your anchor tag? Could send me a link to the page and I’ll try to work out what’s going on based on your outputted markup. Is there any chance there’s a rogue CSS rule at work?

@julia Removing the / didn’t help :confused: I can probably send you a link in the next day or two. Is there a support email I can send it to?

Ps: And not css related. There is no content being output in the div

You’re right. I didn’t address your problem.

I think the ultimate problem is that the relationship loop doesn’t understand it’s in a Beaver Builder loop.

What I do in that case is a bit kludgy, but I set the entire BB post module layout to

[template id=12345 pid=[wpbb post:id]]

Inside that template, create a loop for each single item, which lets you create the relationship loop.

<Loop type="my-cpt" id="{Get local=pid}">
  (enter the stuff you already have)
    <Loop acf_relationship=resource_solution>

That works on an Archive Template page. If you’re on a Singular Template page you can always just add a separate posts module for your ACF relationship info.


Yeah, I could try that and see. I’ll keep that as a backup to try :+1:t2: But to clarify it does understand that it’s in a BB loop as it’s working 1/2 the time (even posts) haha

1 Like

Maybe. Or it could be grabbing half the posts from one side of your relationship and half from the other side which doesn’t offer any data … or something like that.

1 Like

Totally. Who knows at this point. Sent support an email. Hopefully they have some more insights to share :crossed_fingers:t2:

@julia I sent an email to with login info - if that’s not correct, lmk

Hi Zack, I don’t think that email exists! Could you email

Thanks. Sent :+1:t2:

PS: Maybe add support@ as an alias to service@ :wink:

1 Like

Thanks for the access! I have no idea why every other post was working. The relationship loop was getting the context of the Customers page, but I’m not sure why it was displaying anything at all. Adding a post_in attribute with the value [wpbb post:id] and passing it to the loop in the template fixed the issue. I also added an optional post_type attribute in case you use this template for another post type.

Bizarre… Thanks for helping solve though! For anyone in the future, this is what @julia came up with to fix.

<If check="{Get local=post_type}"><Else /><Set local=post_type>resources</Set></If>
<Loop type="{Get local=post_type}" id="{Get local=post_in}">
  <Loop acf_relationship=resource_solution>
    <a href="{Field url}" class="related-solution">
      <span class="label"><Field title /></span>

(For further context above my post type was resources and the acf relationship field was resource_solution)

1 Like

Oh, and here was the template shortcode used in the BB post module:
[template name=customer-story-related-solution post_in="[wpbb post:id]"]

Hi @zack and @RichardC, thanks for your efforts to document this issue. While @julia’s workaround of passing the post id as a variable to the template may work, it’s kinda circumventing the normal way that L&L is designed to work (which is to get the current context of whatever current post/page a template is placed on without needing to pass these as variables to the template). It took quite some effort to find and resolve this but I’m happy to report that in the latest 3.0.0 release of Loops & Logic, we’ve managed to resolve this. From now on, simply adding the [template id=123] shortcode to the Beaver Builder Custom Post Layout editor will correctly get the right post information every time without needing to pass post ID data to the template.

I’ve also been told that the efforts that were put in to resolve this have improved all page builder previews as well as the template shortcode overall so thanks for your help in identifying this issue. It seems we’ve been able to strengthen the foundation of L&L thanks to your sleuthing!


Hey @benjamin, I just tested 3.0 and it didn’t fix the issue (it just make it break in a different way).

I sent you a support email following up to show how it breaks

Hey @zack, I just followed up on your email and I think you simply made an error in the way you removed Julia’s workaround. As far as I could tell from the info in your email, L&L 3.0.0 is working as expected.

Thanks. You’re correct! :raised_hands:t2:

1 Like