Shortcode count number?

New to Loops & Logic and got a template with count=4. If I want to show say 12 in a different place do I need to make a copy of the template or is there some way to make a flexible template and set count number within the shortcode or something?

For what I understand maybe shortcode and variable will be useful for you.
[Template id=123 count=4]

and then inside template call variable using:

<Get local=count/> or {Get local=count/}
1 Like

I see. Many thanks for the explanation.

1 Like

Is there a example how to implement that in the template? I´m pretty new and tried something like this:

<If loop exists type=post>
  <Loop count={Get local=count/}>

    <a href="{Field url}">
      <div>
        <p><Field title /></p>   
      </div>
    </a>
  </Loop>
</If>

Hi Christoph,
You’re really close! All you’re missing as far as I can tell is quotes around your {Get local=count/}

<If loop exists type=post>
  <Loop count="{Get local=count/}">

    <a href="{Field url}">
      <div>
        <p><Field title /></p>   
      </div>
    </a>
  </Loop>
</If>

and then use it like so: [template id=123 count=4]

Should the slash at the end beeing removed as well?
<Loop count="{Get local=count}">

Check out this interesting thing we discovered the other day related to the slash on tags inside attributes. The short answer is that in this case it doesn’t matter whether we leave the slash or remove it. But in some (clearly very rare) cases where there are lots of nested tags in an attribute, the slash can sometimes actually be necessary. I think I’m going to start recommending that people leave in the slashes just to avoid any potential issues. Makes it a bit less pretty though :stuck_out_tongue_winking_eye:

Perfect and thank you all. Even though as a beginner I don’t really understand the / thing, it’s really fun to work with Loops & Logic and to learn more and more with your help.

1 Like

In my case the code only works without “/”

I think that’s because there needs to be a space before the slash like count="{Get local=count /}" otherwise L&L sees count/ as the value instead of count. Not totally sure but that’s my hypothesis.

In any case, no worries if you don’t understand the slash thing, that was more of a note for @PolarRacing since I know he’s got some experience pushing the limits of L&L. In practice, it’s unlikely that you’ll run into an issue by omitting the slash. It’s only if you’re putting a whole bunch of different tags inside your attribute where it starts to matter.