How to customize the eventtop date format
Last Updated: September 6, 2022
UPDATE: previously used evo_eventtop_day_block is deprecated and no longer used. Code updated to EventON v4.1.2
Have you ever come across a situation where you need to change the date format on EventON eventTOP?
Well, you are in luck, the below code snippet will guide you on how to customize your code to show the date in any format you desire.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
add_filter('evo_eventtop_dates','fnc_002', 10,3); function fnc_002($array, $show_start_year, $object){ $start = $object->start_date_data; $end = $object->end_date_data; return array( 'start'=>array( 'year'=> '', 'date'=> $start['n'].'.'.$start['d'], 'month'=> '', 'time'=> '', ), 'end'=>array( 'year'=> '', 'date'=> '', 'month'=> '', 'time'=> '', ) ); } |
CODE Explained:
We are hooking into “evo_eventtop_dates” filter and altering the ‘date’ value of the data array to match to the format you want.
The $object that is also passed into this filter contains: start (array), color, day_name, html, show year, yearlong (boolean) as properties. These properties are arrays and strings.
Start property sends a huge array of various event start date items. These items are broken down into individual date items such as month, day, name etc. In the example above, we used “n” which represents the month as an integer and “j” which represents the date as an integer. You can refer to the date format string at http://php.net/manual/en/function.date.php for more information.
In this code you dont necessarily have to return the end array values, but I have added in there so you can see how to alter values for that part of the event date as well.
Just passing a new custom value for start > date will show 5.31 and will use the the biggest font to show all the text in bigger font.
Using this information, allows you to easily customize the look of eventTop date format. The above example will look like the format below:
Did this article help you? If not, send us a ticket via helpdesk