1

I'd like to return 5 entries from 5 channels in a list, the list being comprised of:

  • the one most recent entry from each channel
  • in order of date

A simple exp:channel:entries loop with a limit of 5 and channel="blog1|blog2|blog3|blog4|blog5" will bring back the 5 most recent entries overall, but not just one entry per channel.

And 5 channel:entries loops will bring back the most recent, but not with them in the right order -- and the overhead of 5 channel:entries loops makes me cringe.

How would you do it?

1 Answer 1

3

You're in custom plugin territory Travis. Pretty easy though.

  • Run one (very quick) query to get the latest entry_id in each channel (query exp_channel_titles only). Save them all to an array.
  • Then, you can either return those entry_ids as a variable (concatenated with |), which you pass to your channel:entries tag in your template, or instantiate a new Channel instance and return it directly.

See this great answer on a related question by Adrian for some sample code.

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.