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.

Cheers,

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 support@loopsandlogic.com with login info - if that’s not correct, lmk

Hi Zack, I don’t think that email exists! Could you email service@tangibleplugins.com?

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>
    </a>
  </Loop>
</Loop>

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

1 Like