1

I would like to show a list of recent entries, restricting the list to one per author. Essentially the logic I'm looking for is "show 10 recent articles, but if the author of the next article already has an article on the list, skip it."

I'm thinking I'll have to use PHP to add a second level of logic, but I'm hoping someone else has an idea.

A possible kink: I'm using Solspace's User.

  • I suppose it could be approached from the other direction — list all authors and their most recent entry, then re-sort based on entry ID or date. – Tim Aug 13 '14 at 16:26
  • Small FYI note: Solspace User works alongside the native EE Member module, so member_ids are used and stored the same way as native EE. In other words, nothing changes for an entry author whether User is installed or not. – Solspace Aug 14 '14 at 2:21
4

You might could do something like this (php must be enabled on input)

<?php
$entries = array();
$sql = "SELECT author_id as author, 
        max(entry_id) as entry_id 
        FROM exp_channel_titles
        WHERE channel_id = '4'
            AND status = 'open'
        GROUP BY author 
        ORDER BY entry_id DESC 
        LIMIT 10";
$authorEntriesQuery = ee()->db->query($sql);
foreach($authorEntriesQuery->result_array() as $row)
{
    $entries[] = $row['entry_id'];
}
$entriesString = implode('|',$entries);
?>
{exp:channel:entries channel="blog" entry_id="<?echo $entriesString?>"}
{title}<br>
{/exp:channel:entries}

You would have to change the channel number obviously and if you have any custom statuses you need to account for, then change that section.

I tested this and got the most recent posts from individual authors.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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