Entries Related by Category with Filler Entries After At the bottom of an entry I want to display links for eight other posts. To make this useful, what I'd like to do is:


start with entries that are related to the post currently being viewed by category (generally there are 4-5 of these)
then fill in the remain slots with the other posts (not related by category), newest first


Is there a simple-ish way to do this? I started down the path of separate queries, counting, and merging results but something about that feels more complicated that it should be. I'm wondering if this can be achieved via ordering or grouping?

Thanks in advance.
This is probably pretty much the same code you already have, but I can't think of a more elegant solution:

{% set relatedEntriesIds = craft.entries.section('news').relatedTo(entry).limit(8).ids() %}

{% if relatedEntriesIds|length &lt; 8 %}
    {% set moreRelatedEntriesIds = craft.entries.section('news').limit(8 - relatedEntries|length).ids() %}
    {% set relatedEntriesIds = relatedEntriesIds|merge([moreRelatedEntriesIds]) %}
{% endif %}

{% set relatedEntries = craft.entries.id(relatedEntriesIds).fixedOrder(true) %}