Forum

Thread tagged as: Question

Perch Region Auto-Delete Function?

Hello everyone,

I'm inquiring on a possible function, if said function exists.

I'm looking for a perch region option that deletes the region after a set time.

For example, a job posting that disappears after a certain date without the user logging in and manually deleting the region.

Cheers, Matt

MATTHEW URSO

MATTHEW URSO 0 points

  • 2 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Matthew,

In the case of a job posting, you would add a date field to the region and use the filtering options with perch_content_custom() to only display the region before that date.

https://docs.grabaperch.com/functions/content/perch-content-custom/#filtering-content

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you want to set a closing date in the content itself, use a filter. Here the filter assumes the content has a date field called expires.

perch_content_custom('Job postings', [
    'filter' => 'expires',
    'match' => 'lte',
    'value' => date('Y-m-d H:i:00'),
]);

Thanks guys! Much appreciated. This ended up working for me.

<?php perch_content_custom('job-opportunity', [
'filter' => 'expires', 
'match' => 'gte', 
'value' => date('Y-m-d')
]); ?>