TransWikia.com

Display Count of Entries posted today

Craft CMS Asked on July 28, 2021

I’m trying to display a notification badge on how many new entries were posted today only. But I cannot get the following to work.

{% set timeAgo = now|dateModify('today') %}

{% set recentMerchantsOffers = craft.entries.section('offers').postDate(timeAgo).relatedTo(recentMerchants) %}

Any help would be great 🙂

One Answer

I'm not sure what recentlyViewed() is and what it returns but to query today's entry, you can do:

{# Today in atom format #}
{% set timeAgo = date('today') | atom %}

{% set recentMerchantsOffers = craft.entries()
    .section('offers')
    .postDate(">= #{timeAgo}")
    .all() %}

Correct answer by Oli on July 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP