0

I have this tag which pulls entries from all categories:

{exp:channel:entries channel="foto" category="1|2|3" limit="15" }
   //content
{/exp:channel:entries}

Is it possible to pull 15 entries per category? So it would result in 45 entries in total?

I want to shuffle it afterwards therfore I don't want to call this tag three times.

6
  • ... What happens when you put a limit of 45? Does it evenly pull 15 per category?
    – jrothafer
    Commented Sep 25, 2015 at 17:31
  • It just pulls 45 entries from the first categories since there are more than 15 entries per category. If there would be 10 entries in the first category it would pull 10 from the first and 35 from the second category.
    – KSPR
    Commented Sep 25, 2015 at 17:47
  • Also, if you are going to shuffle it after (I assume jQuery), why does it matter if you call it three times in a series?
    – jrothafer
    Commented Sep 25, 2015 at 18:12
  • I'd prefer to use orderby="random".
    – KSPR
    Commented Sep 25, 2015 at 19:15
  • As for the limit="45" path, if you put your three categories in a category_group, does that give better results (output even amounts from each category?) I can't imagine it will, but it's worth a shot....
    – jrothafer
    Commented Sep 25, 2015 at 19:21

1 Answer 1

1

If you create a category group with your three categories, you can set the category_group param on your entries loop. This will pull a rounded, even amount of entries from each category in the group. In an example where you have three categories in category_group 1:

{exp:channel:entries
    channel="catburgers"
    category_group="1"
    limit="9"
    orderby="random"}

    {!-- This will output, in random order, 9 entries from the category group, 3 from each category --}

    {title} - Catburger

{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.