I have events pages that feature a single event that then need to be displayed on a custom calendar on another page. I need to use perch_content_custom() to display all the posts that occur in a specific month but I cannot get the filtering to work properly. Here is my code for the month of august:
- <?php
- perch_content_custom('Event Details', [
- 'page' => '/events/*',
- 'filter'=>[
- [
- //filter for all events in specific month
- 'filter'=>'event_date_start',
- 'match'=>'contains',
- 'value'=> '-08-', //month of august
- ],
- [
- //filter for events that have not yet occurred
- 'filter'=>'event_date_end',
- 'match'=>'gte',
- 'value'=> date('Y-m-d H:i:s'),
- ]
- ],
- 'sort'=>'event_date_start',
- 'sort-order'=>'ASC',
- 'template' => 'event_short.html',
- ]);
- ?>
The ID event_date_start is a standard date fieldtype so the data is in the form of Y-m-d H:i:s My thinking is that 'match'=>'contains' would be able to find the month within the date string but it isn't working. I put dashes before the number (-08-) because only the month has a dash before and after it's number. Maybe I need to use 'match'=>'regex' ? I looked for examples of using 'match'=>'regex' and could never get it to work. Kind of at a loss at this point. Any ideas?