My CCS Shortcut replacement

In locations where a shortcode was required, CCS allowed me to show the content of any post with
[content id=42166]

To accomplish that In L&L, I use
[template id=123 ptype=dogs pid=456]

Which calls a template I’ve named Content

<Loop type="{Get local=ptype}" id="{Get local=pid}">
  <Field content />

If that’s the optimal way to do it, I hope this is useful to someone else.

If there is a better way, I’d love to hear about it.

Cheers, Richard

1 Like

That is indeed the correct approach to getting post content with a shortcode.

Nice job figuring out tag attributes as local variables for templates! It’s one of my favourite features :slight_smile:

For anyone wondering, you can create a similar shortcode for any field by swapping out <Field content /> in Richard’s example, and here’s the relevant documentation

1 Like

Hi Richard, thank you for sharing the useful snippet to load post content from a shortcode. I like how you used shortcode attributes to pass local variables.

I wanted to mention, there’s a newly documented feature for the Field tag called loop type shortcut. It’s a way to set type attribute with id or name, to avoid having to create a loop.

So the template can written as:

<Field content type="{Get local=ptype}" id="{Get local=pid}" />

It’s suitable for one-off use of a field. If more than one field is needed, it’s more efficient to create a loop.

Anyway, I thought you might appreciate this trick. :slight_smile: