ACF relationship Loop not displaying in the frontend

Hi everyone!
My issue is quite a specific one, and I guess it has more to do with L&L execution than the code itself. Let me explain.
I have this bit of L&L code:

<Loop acf_relationship=liencoursclassezoom >
    <Field acf_textarea=shortcode_classe_zoom />

I integrate it via Elementor, on a CTP called “Lesson” from the MasterStudy course plugin that I link to another CPT with Zoom classes. When I’m in the Elementor editor, it is properly displayed. But on the frontend, on the course page itself, the space is blank. That is because the ACF relationship Loop part isn’t going through for some reason. I’ve tried looping the Zoom CPT directly, and it works properly. Though, I need to select only the Zoom class linked to the lesson, hence the ACF Relationship.
Would there be another way to achieve this without going through the ACF Relationship field? Or maybe another way to write the L&L Code? Although I insist that my bit is working in the Elementor Editor or on other pages than the “Lesson” CPT. Indeed, the lessons are rendered in a specific way by the MasterStudy Plugin, which is, I guess, the cause of this issue.

Any help would be appreciated!

I can see in the docs that the ACF text area field can just be displayed with the Field tag, so I would assume you should be able to simply write <Field shortcode_classe_zoom /> instead of acf_textarea=. I’m not seeing that attribute documented anywhere so I’m surprised to hear that it seems to be working part of the time for you! Since that does seem to be partially working for you, I doubt that’s your issue, but I thought I’d mention it just in case.

I saw your post on the WP plugin support forum (sorry it’s been taking such a long time to respond to that) which suggests that this is specifically an issue with MasterStudy. I don’t have the premium MasterStudy theme so I can’t test with that, but to try to get to the bottom of things I went ahead and installed MasterStudy to test it myself. I created an ACF relationship field called lesson_link to associate a “link” CPT with a MasterStudy lesson.

I also made a basic link text field to write a URL on my “link” CPTs.

Then I created a new link post called “Google” and added “” as the text value of my link custom field.

I also created a new lesson in MasterStudy called “My Google Lesson” and I associated it with the “Google” post I created above using the ACF relationship field I made for this. I wrote a super simple template that looks like this and added it to my lesson page using Elementor.

<Loop acf_relationship=lesson_link>
  <Field link />

And as you can see below, it’s successfully displaying the link field from the post that’s linked through my lesson_link relationship field.

So all that to say that I’m not currently seeing an issue and I’m unclear on how to replicate the behaviour you’re seeing to figure out if this is a glitch or not. Could you elaborate on how you’ve added the template to your page and how you’ve identified that “the ACF relationship Loop part isn’t going through”? Does the text field associated with the post that’s linked through your relationship field get displayed if you simply write <Loop acf_relationship=liencoursclassezoom ><Field shortcode_classe_zoom /></Loop>?

Hey! Thank you so much for the answer, I really appreciate the time taken and the lenght you went to to actually replicate my issue.
I just checked again the documentation, and there is indeed no sign of that textarea= thing… I must have gotten carried away…! I’ve checked your process, and that is indeed very similar to what I need. What I put in the textarea field is actually a shortcode, so I added the tag to your code, and unfortunalty, it resulted is the same outcome as my previous code (although in a much cleaner manner :laughing:)
As for your last question about how I determined that the ACF relationship was in cause, here is what I can say. I’ve tried Looping through the “Zoom meeting” post type and get the ID Field, and it worked properly as all IDs were displayed. Only when I loop through the ACF relationship, it resulted in the blank result.
In Elementor Editor

In the frontend

I tried the Post Object, but to the same amount.

So I tried a different approach, much more complex, and here is what I got so far :

<Set name=zoomusercourse>
  <Field acf_user=student_course_zoom />
<Loop type=stm-zoom>
  <Set name=zoomid>
  <Field id />
<Loop type=stm-zoom>
  <Set name=zoomuser>
  <Field acf_user=student_course_zoom />
<If field="{Get zoomusercourse}" is field="{Get zoomuser}">
  [stm_zoom_conference post_id="<Get name=zoomid />"]

This is working very fine. I tried to simulate the relationship through L&L instead of ACF.

  1. I set a user ACF field in both Lessons and Zoom Meetings
  2. In the Zoom Meeting, I only have to set the user once
  3. In Lessons, I pick the user for whom the lesson through this same ACF User field. It’s not longer than to pick through a Relationship link
  4. In the L&L code, I both the ACF User Fields (in lessons + in Zoom meetings)
  5. I also set the other information I need from the Zoom Meeting Post type, in this case, just the ID which is the part of the shortcode that matters
  6. I compare both ACF User Fields, and if they’re the same, then I insert the ID in the shortcode.

I’ve yet to set this for every other user, it now just works on one. I’ll try and keep you in touch very soon. It’s not a fix, but rather a workaround, but hey, if it works! :wink:

If you simply write this in your template (basically removing the Shortcode tag), does the text content of your field get displayed on the front/back end?

<Loop acf_relationship=liencoursclassezoom >
  <Field shortcode_classe_zoom />

I’ve gone ahead and tested it on my demo site that I had set up with MasterStudy and when I add a shortcode to my ACF text field and then pull that onto a page with L&L, I’m successfully able to display either the shortcode text (if I don’t wrap it in the Shortcode tag) or the output of the shortcode (when I wrap it in the Shortcode tag). So this is all still working as expected for me and I’m not seeing the issue you’re describing.

Are you able to share the full template markup contained within the “Test Zoom” template that seems to be causing you issues?

The fact that I’m not able to replicate this on my own test site (which only has the basic plugins installed necessary to test this) suggests that this issue is may be coming from a conflict with a third-party plugin. Are you able to test for potential conflicts by disabling plugins on your site to identify whether this is the case?

Would you be willing to create an admin account for and send a link to the page where this issue is happening? Maybe if I was able to see this in context it would be easier to troubleshoot.

Hi Benjamin,

Thank you for your time again.
I’ve tried to determine whether there is a plugin conflict. Used to Twenty Twenty Two theme, and kept activated only :

  • Elementor (basic)
  • Masterstudy (basic)
  • ACF
  • Tangible
  • eRoom plugin (basic)

The last one, eRoom, is the one allowing me to have shortcode for Zoom and display what I want to display. I’ve created my ACF fields on this Post Type. With you L&L bits, I ended up with the shortcode displaying in the Elementor Editor, but not in the frontend. I’m now starting to suspect that it has to do with the eRoom post type where I implement my ACF fields. Maybe you could try, on your install, to add this eRoom plugin and try to implement your ACF field here, and see if you can reproduce the issue?
Except from this, our configs should have been the same I guess. :slightly_frowning_face:

As for your other question : I’m sorry I don’t understand what you mean by full template markup for the Test Zoom. :sweat_smile:

If this eRoom plugin doesn’t reproduce this issue, then I’ll give you access so you can investigate. This plugin has caused me problems in the past, so that might be it. And in that case, nothing prevents me from creating another CPT to implement my ACF fields there…

A last question: is my workaround option bad codewise/performancewise? Because if not, I could totally work with that, even though I understand I should be able to create this in a more simple fashion.

Thanks a lot

I was just wondering if the markup you shared in your initial post was the entirety of the markup contained in the L&L template you made or if there might have been some other markup that you hadn’t shared that might have been causing this conflict. “Test Zoom” was the name of the template you were using in your screenshot. If the markup you shared initially was the whole thing then I guess that might not be where your issue is coming from.

I’ve installed eRoom on my little test install and it seems to be working for me. Here’s what I did:

  1. Created a new meeting in eRoom (post ID is 60). I didn’t go through all the effort of connecting my Zoom account, just created a sort of empty meeting post for the sake of testing.
  2. Created a new custom post that contained an ACF text field which contained the shortcode [stm_zoom_conference post_id=“60”]
  3. Created a MasterStudy lesson and associated the lesson with the custom post I made in step 2 through an ACF relationship field
  4. Edited the lesson in Elementor and added a Tangible Template widget that links to my L&L template which just includes this simple markup: <Loop acf_relationship=lesson_link><Shortcode><Field link /></Shortcode></Loop>

You can see in the screenshots below that I have my Tangible Template displaying the output of the shortcode above and the same shortcode below being directly added to a text editor widget. Both seem to be outputting the same thing, which means that the L&L side of things is working correctly and outputting the shortcode as expected. You can see that the shortcode doesn’t quite seem to be displaying properly in the Elementor editor (you can see in the screenshot below that the “Meeting starts in” text appears but not the countdown timer) but when I view the page from the front end, the heading and countdown timer show up. The output of the shortcode seems to be the same whether it’s being called in through L&L or directly through the text editor. The fact that I’m seeing a difference in what’s being displayed on the front end vs the editor regardless of whether L&L is used to call in the shortcode suggests that this is an issue with eRoom, not L&L.

Here’s the view in the page builder:

Here’s the view on the front end:

And to respond to your last point:

I honestly don’t fully understand what your workaround L&L markup is doing, although part of that might be because I’m not intimately familiar with your site’s data structure. There are four things that jump out at me that suggest there might be some confusion.

  1. You seem to have two identical loops (<Loop type=stm-zoom>) one after the other. This means that you’re running two database queries to get the same content, which seems unnecessary. It seems like you should be able to set both variables within a single loop.
  2. Your markup seems to be looping through every single post of type stm-zoom and setting/resetting your variable once each time the loop runs (once per post in the loop). I don’t fully understand your data structure, but my gut assumption is that you might be testing this with a single stm-zoom post for now and it’s working, but if that’s the case then this won’t work once you have multiple stm-zoom posts. I might be wrong because like I said I’m not sure what your data structure is.
  3. Your <Field acf_user=student_course_zoom /> line seems to again be syntax you’ve invented that doesn’t follow the docs. ACF’s “user” custom field can contain references to multiple users, so the L&L integration for that type of field is used for looping through the user fields of each user referenced in the ACF user field. The syntax you’ve used isn’t something I can find any reference to in the L&L documentation and the way you’ve used it seems like you’re just grabbing the field value of that ACF user field (as opposed to the fields from the users themselves), which I don’t think would require using that acf_user attribute since I’d assume <Field student_course_zoom /> would be enough to get you the user ID contents of that ACF user field. If that’s the case, then there’s not even a need to set a variable at the beginning as you’ve done, since you could just write is value="{Get student_course_zoom}" in your If statement.
  4. The final issue I’m seeing is at the end of your if statement when you write is field="{Get zoomuser}". zoomuser isn’t a field, but a variable you just defined earlier in your markup. field is also not a valid way to end your conditional statement, since the field attribute only works with an optional value attribute as noted in the docs. Since this isn’t valid syntax, I wonder if your conditional statement is actually working like <If field="{Get zoomusercourse}" exists />, which I assume isn’t what you intended.

I’m impressed/surprised that your markup works for now, but my assumption is that this won’t work for you long-term. It also demonstrates some misunderstandings about how L&L works, so you might want to read up on the blog posts about L&L best practices to clear those up.

So in the end, it seems that there might be some issues with eRoom and Elementor that could be causing this issue. However, since your [stm_zoom_conference post_id="<Get name=zoomid />"] markup is successfully displaying content for you (unlike me), this could also mean that in your case, there’s some other conflict causing this which either results from misunderstandings about L&L syntax or something going on with your site’s data structure. If there is an issue with L&L’s acf_relationship functionality, it’s not apparent from this thread.

Your troubleshooting skills have been impressive and creative so far so I hope that you’re able to take some of the ideas/pointers in this post along with the blog posts linked above to help you get this working as you need it to. Best of luck with this!

Thanks again for your time and patience, it’s much appreciated.
I’ve actually just noticed something in your testing that would explain why you can’t reproduce the issue. I should have noticed it before, sorry. Actually, you are visualizing the lesson you created by just showing the lesson page: I noticed this by looking at your url structure. In this case, everything is working properly, even for me.
But if you create a course and add this lesson in it, and try to access the lesson via the course, only then the issue occurs. I actually talked about this side of a problem a bit more extensively on the WP forum (I saw you replied there too, and I thank you for this). This being said, it is pretty obvious that L&L isn’t at fault, and that the Masterstudy’s way of rendering the lessons into the courses is what causes the issue. Therefore, maybe I shouldn’t have brought the issue to the L&L forum, but at least if someone is facing the same problem, he’ll have something to rely on to better understand what’s going on.
I thank you for feedback on my code. I am indeed an amator in this field, so thanks a lot for you feedback, I’ll study the documentation some more and take into account your advice. If you allow me to keep this thread open for some more time, I’d be glad to add a final reply with a working and cleaner L&L code when I’ll have done some more troubleshooting.

1 Like

Ah understood, you’re right that it does display differently when the lesson is inside a course. I wonder if MasterStudy is somehow displaying fields related to the course instead of the lesson; maybe there’d be a way to work around that with L&L. In any case, I’m glad we were able to get to the bottom of this and understand where this issue is coming from. Weird that MasterStudy is ignoring really basic conventions related to the standard WP default loop. I hope you’re able to find a way to rewrite this now that we know what’s causing it, please feel free to keep this thread updated with whatever you find!

Also, if your site is still in development and you’re open to alternatives, we’re actually working on native LearnDash and LifterLMS integrations for L&L. So if you’re willing to switch from MasterStudy to either of those options, you’ll get a ton of utility out of L&L once we launch those integrations.

Best of luck with this!

Hi there,

Just a follow up on the issue, although I have no solution yet.
After some debugging to better understand why nothing was displayed in the course interface, I think I understood where the liability resides.
By simply asking for a <Field id />, I noticed different values were returned whether the lesson was displayed inside of the course or just as a simple post. So I guess that, them having different IDs means that the ACF field I create on the lesson actually doesn’t exist on the lesson displaying inside of the course. :expressionless:

Interesting, that pretty much cements our hypothesis that masterstudy is changing the default loop context when lessons are placed inside courses. I’ve never heard of a WP plugin doing that. I wonder which post id it’s displaying in each of those contexts. I’d assume when the lesson is on its own, it’s displaying the lesson post id, but maybe when the lesson is put inside a course, it displays the course post id instead. Weird. Good troubleshooting though! Hopefully, masterstudy can address this although, from the reviews I’ve seen, it sounds like their support isn’t particularly responsive.

There might be a way to force a change in loop context if there’s somehow a field on the current course post that indicates what the current lesson is. I’m not sure what that would be though, but if that data is in a field, you might be able to wrap your whole template in some kind of <Loop type=masterstudy_lesson id="{Field associated_lesson}">. Those are obviously the wrong values because I don’t know what post type names or field names masterstudy uses, but if you can figure those out, you might be able to get this to work even if masterstudy doesn’t fix their plugin to make it work like every other WP plugin. Best of luck with this!

Further troubleshooting leaded me to understand that it is the last blog post’s ID. This is a nightmare, as I don’t seem to be able to get a single info via L&L that allows me to link the lesson in the course to anything, as every <Field /> request points to the last blog post instead.
Their support is indeed so unhelpful most of the time that I haven’t renewed it after it expired :grimacing:
I’m now so desperate that I’m trying to pick up the current user info (as only me and the student can access the class), and compare it with an acf_user field in a CPT where the Zoom ID is also stored.
So here is how my date is now structured.
Masterstudy Lesson & course : nothing is stored here, but only designated student can access it
CPT course_recap : I store here with ACF post a link to the corresponding Zoom meeting (zoom_suivi) and with ACF user a link to the student/students’ accounts (etudiant_suivi)

So here is the code, please feel free to point out any syntax that I might have (and sorry if I did again) invented :grimacing: :grimacing: :grimacing:

<Set name=userid>
  <User id />
<Loop type=course_recap>
<If field=etudiant_suivi includes value="{Get userid}">
  <Set name=zoomid>
<Field zoom_suivi />
<Shortcode>[stm_zoom_conference post_id="<Get name=zoomid />" hide_content_before_start=""]</Shortcode>

This is, so far, working with only 1 CPT (course_recap) created. I’ll be testing with more.

EDIT: changed check to includes to support the case of group courses with several users.

Seems like a smart way of doing it! I’m not sure I can help you with actually getting this to work based on your data structure, but if it’s working now then keep testing edge cases to make sure your solution fits all your needs.

I can however point out a couple of opportunities to fine-tune your template, although it’s pretty minor stuff and you’ve clearly got the hang of it. No invented syntax hahaha! Here’s how I’d write it, which is basically the exact same thing you wrote, but without unnecessarily setting/getting variables. The only difference is that in theory if there are multiple items in the loop that match your logic, doing it this way could display the shortcode as many times as there are items that match. But it sounds like there should probably be only one match based on what you’re describing, so maybe this isn’t an issue in your use case. I’ve also been meaning to flesh out this comment from Eliot into a page in the docs, but you might want to read through it since this would probably be an opportunity to filter your loop with some attributes in your loop tag instead of using conditional logic inside your loop. It might be the same level of performance, but your template would be a little shorter and cleaner. Anyway, here’s an initial pass to remove the unnecessary variables:

<Loop type=course_recap>
  <If field=etudiant_suivi includes value="{User id}">
    <Shortcode>[stm_zoom_conference post_id="{Field zoom_suivi}" hide_content_before_start=""]</Shortcode>