How would I order the latest 3 entries from a channel with each entry from a different author? (so they don't end up being 3 latest entries by the same author) - I think I need to use an SQL Query for it?
{exp:channel:entries orderby="screen_name|date" channel="portfolios" limit="3" group_id="5" dynamic="no"}
<img src=" {thumbnail}" alt="{title}"/><br />
{title}<br />
{/exp:channel:entries}
Thanks in advance!
Mark - here's a repost of the answer I posted on the other dupe question:
The best approach here, since you need your custom fields parsed, is to first find the entry_ids of the latest 4 entries from distinct authors, and then pass those to the
channel:entries
tag through an embed using theentry_id
parameter.This should work (be sure to replace the
channel_id
with the appropriate integer). Replace your entire current chunk of code with this:Then your embeds/_latest_per_member template can look something like this:
You had mentioned that this code gave you a recursive error - that means that you've put another call to the embed within the embed. Don't do that.
The WHERE IN (SELECT MAX(entry_date)...) example took a huge hit at the database. It seems to essentially do a subquery for each entry. An alternative i found (Stackoverflow) uses just one subquery in the FROM part,
quote: Do a GROUP BY after the ORDER BY by wrapping your query with the GROUP BY :-).
Anyway ... This fetches all authors and their last posted entry title. If you also want the url_title, you have to add it to both SELECT statements. I've included some extra options, fetch only for the last 4 months, limited to channel_id 8, and limit to category_id 68.