I’ve made two custom post types, one of which (style-section) is the parent of the other (style-rule), and has a relationship field that connects the two. On the parent posts I want to loop through the related child content.
If I use an actual post ID (206 in this example, below) this works. But I want to dynamically get the post ID of the current post, and I haven’t managed to find a way to do this.
Hey @juliush, welcome to the forum! Glad to see that you’ve managed to figure it out yourself
While the code you’ve shared achieves what you’re trying to do, I thought I’d chime in with a tip to improve the performance of your L&L markup. In your case, there’s no need to use Set and Get to define and use a custom variable because you could just as easily reference the Field id in your loop’s query parameters like this:
You might find the this section of the “Getting started with L&L terminology and syntax” article useful as further reading to better understand how to use pass dynamic data to a tag attribute.