1

I have an entries field that can be used to select entries to be featured. I know I can remove the featured entries from the loop with this:

{% set query = craft.entries.section('blog') %}
{% set featuredIds = entry.featured.ids() %}
{% set query = query.id(['not']|merge(featuredIds)) %}
{% paginate query.limit(5) as pageInfo, entries %}

so then I can loop through both the featured entries and then the non-featured ones.

What I can't figure out though, is how to maintain the number of entries on the first page. For example, if there are 3 featured entries, with the way things are now, I'd have 3 + 5 on the first page but then 5 on every page after that.

How do I have it so I'd have 3 featured + 2 non-featured on page 1 and then the rest 5-per-page as normal?

1 Answer 1

1

This seems to be what I want:

{% set featuredIds = entry.featured.ids() %}
{% set notFeaturedIds = query.id(['not']|merge(featuredIds)).ids() %}
{% set allEntries = featuredIds|merge(notFeaturedIds) %}
{% set query = craft.entries.id(allEntries).fixedOrder(true) %}

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.