How to customize the eventtop date format
Last Updated: December 30, 2024
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.
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?
- Code snippets
- CODE: To add additional healthcare guidelines
- How to add new social share icons
- How to change "events" slug & rewrites
- How to customize the eventtop date format
- How to hook into eventTop
- How to increase event type category count
- How to load EventON scripts to a page
- How to show additional custom data in the eventCard