I have a requirement where I need to display entries from one channel, but entries get might show up 5 days after post date, show up if externalListingOnly or show up immediately if internalAndExternalImmediately

I've got this working with the following code:

{# show only entries more than 5 days old #}
{% set dateRestriction = now|date_modify('5:00 -5 days') %}
{% set postDateParam = '< ' ~ dateRestriction|date('U') %}{#'M d, Y'#}

{# get entries that are added after 5 days after postDate #}
{% set entriesDelayed5 = craft.entries.section('careers')
  .all() %}

{# get entries that are only external #}
{% set entriesExternal = 
  .all() %}

{# get entries that are internal and external immediately #}
{% set entriesBoth = 
  .all() %}

{% set entries = [] %}
{# merge all options here #}
{% set entries = entries|merge(entriesDelayed5)|merge(entriesExternal)|merge(entriesBoth)| supersort('sortAs', '{title}') %}

{# {% for entry in craft.entries.section('careers').orderBy('title').postDate(postDateParam).all() %} #}
{% for entry in entries %}
{% endfor %}

However the entries display in the order that they are merged in and I need them to display alphabetically by Title

I tried the supersort plugin but got a php error about being nested too deep. Not sure why or how to resolve that.

Please advise.

Your Answer

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

Browse other questions tagged or ask your own question.