Macro question about reusing code for different loop types

Hey Richard, you’re on the right track! I think what you’re looking for is the Template tag. That tag allows you to nest loops inside other loops to your heart’s content and is probably the most useful (and most underused) way to build sites with L&L since it allows you to more easily follow DRY development principles.

I’m also not sure about the greater context of the markup you’re writing, but I thought I’d share another tip just in case. I saw some of your recent posts (like this one) where you’re manually writing out a custom variable in your shortcode to define the current “post id” so that you can reference it later in your template. Just in case, I thought I’d mention that when it comes to passing data about the current post (the post on which the template or shortcode is placed) to the template, it’s unnecessary to pass information like the current post ID to the template since L&L is already using the current post as its context.

In other words, keeping with your “dogs” site theme, let’s say you had a template that just contained <h2>This dog's name is <Field title /></h2> and nothing else. If you used the shortcode to reference that L&L template on one of your “dogs” posts, the template would already know that you wanted to display fields from the current post so there wouldn’t be a need to feed data like the post id to the template. However, if you were on the home page (for example) and wanted to use the template shortcode to display fields from a specific dogs post, then passing that info as a variable would certainly be a good way to go. Not sure what your use case is but I just thought I’d mention it just in case that helps you avoid having to write extra markup!