Created
April 15, 2025 08:08
-
-
Save terryupton/cd2c1ffcaff54922e42ac9b53e8400c1 to your computer and use it in GitHub Desktop.
Revisions
-
terryupton created this gist
Apr 15, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ {# Fetch the next **pending** entry due to go live #} {% set nextToCome = craft.entries() .section('articles') .status('pending') .orderBy('postDate asc') .one() %} {# If there is no entry due to go live, cache the fragment for a year (change to what you need) #} {% set cacheExpiry = nextToCome ? nextToCome.postDate : now|date_modify('+1 year') %} {% cache until cacheExpiry %} {# Query in your cache tags #} {% set items = craft.entries .section('articles') .orderBy('postDate asc') .all() %} {# Your loop... #} {% endcache %}