Forum

Thread tagged as: Question

Expiring content on a set date

Seems like this should be so simple, but after reading the forum/documentation for a couple of hours haven't found an answer.

Is it possible to expire entries on a set date so they no longer show on the site. I have a date field titled "expire" that I'd like to set so that the entry stops displaying after that date. I currently have this is my page:

perch_content_custom('Jobs', array(
    'template' => 'job_listing.html', //use the template found in the perch folder
    'sort'=>'start',
    'sort-order'=>'DESC',
//     'count'=>1,
//     'filter'=>'expire'
//     'lte'='expire'   
    'filter'=>array(
        array(
            'filter' => 'start',
            'match' => 'gte',
            'value' => date('Y-m-d 00:00:00')
        ),
        array(
            'filter' => 'expire',
            'match' => 'lte',
            'value' => date('Y-m-d 23:59:59')
        ),
    ),
));

and this in my template:

<perch:before><ul class="plain"></perch:before>
<li><perch:content id="start" type="date" format="%D" /><a href="detail.php?s=<perch:content id="slug" type="slug" />"><perch:content id="title" type="text" />, <perch:content id="landtrust" type="text" /></a></li>
<perch:after></ul></perch:after>

Not even sure where to start to get this working.

Thanks, Tim

Timothy Swan

Timothy Swan 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The expiry date needs to be greater than the current date. i.e. in the future.

The expiry date entered into each of the test entries are indeed in the future. Do you see anything incorrect in the code that I'm using?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you're looking for items where the expiry is less than the current date - that's the past. It needs to be greater than, doesn't it?