Issue with Beaver Builder preview when adding templates with acf_relationship loop to a layout

Thanks so much for this. It works with one wrinkle.

When I add my Tangible Template to a singular BB layout the preview section switches from showing post title and content to showing "Lorem Ipsum… " for both title and content. Everything else on the page goes blank.

It seems the preview system is confused by the Tangible Template. I’ve run some tests:

  • It doesn’t matter if I Use an Existing Template or enter it into the BB Tangible Template

  • Complexity and pagination are not the issue. Only entering this is enough to duplicate the problem:

<Loop acf_relationship=make-model>
  <Field title />
</Loop>

The front-end output is correct, but previews in the BB editor no longer work. I sometimes see this problem come or go when I save the Tangible Template while still editing the BB template. Sometimes I need to save the BB template and reload to see the results.

Please let me know if I can add more information or conduct more tests.

Cheers, Richard

Hi @RichardC, I split this post out of the previous thread since, as you said, it doesn’t pertain to relationship loop pagination. I added a title based on my understanding of your issue but feel free to change that if necessary. I’ve managed to replicate the issue and it seems like it doesn’t only happen when you add a template that contains an acf_relationship loop to a BB layout; it also seems to happen any time you add an L&L tag that references a field that exists on the post to which the template will be applied but does not exist on the pot template itself (e.g. adding <Field image /> to the page broke the preview since there’s no image field on a template, but <Field title /> didn’t break the preview since there is a title field on both the template and the post to which the template will be applied). I assume @eliot is going to need to be involved in addressing this.

Here’s what I’ve found out about this on my own little test site. I’ve got a CPT called “My second course” and a BB layout called “ACF Relationship test”. When I add a basic post loop (<Loop type=post><Field title /><br /></Loop>), the BB layout preview page shows the two posts I have on my little testing site as you’d expect, followed by the content of the “My second course” page that I’m previewing:

However, when I create an acf_relationship loop in the Tangible Template, I’m seeing the following occur:

  • The page content that used to be previewed from the “My second course” page is now just showing up as “Content Area.”
  • The text before and after the acf_relationship loop appears correctly, but not the contents of the relationship loop. The contents of the loop appear on the front end, but not on the preview.
  • The part of my L&L template that contains <Field title /> is replaced by the title of my BB layout (“ACF Relationship test”) instead of the title of the page I’m trying to preview. I’m not sure if this is the expected behaviour for L&L, but it seems like L&L is taking its context from the BB layout instead of the page that’s selected in the BB “Preview As:” dropdown. This might not be related to the reason that BB’s preview is breaking, but I thought I’d mention it just in case.

Thanks for pointing this out, we’ll see what we can do to address this!

1 Like

@benjamin, thanks for confirming there is a problem. What’s weird about my case is that to my knowledge, I don’t have the ""Lorem Ipsum… " paragraphs anywhere on my site. Beaver Builder must have them as a fallback in case it doesn’t know what to do.

As stated, I’ll be happy to test future versions if needed.

Richard

1 Like

Thank you for the issue report, and exploring various test cases.

It sounds like a bug for sure, something about the default context of WP_Query, and what “current post” means in an L&L template preview within a BB layout. I’ll dig into related code to see what’s happening and how to solve it.

2 Likes