End date
-
Hello, thank you for this plugin!
I have some calendar items that last a week (a school holiday, for instance). How can I display that in the calendar?
-
Because displaying the entire date range would be too long, and because different languages display dates in different formats, the standard is to display only the start date.
You can use the parameter $end_date_value to display it, referring to Hooks in the following document.
https://info.cseas.kyoto-u.ac.jp/en/links-en/plugin-en/wordpress-dev-info-en/google-calendar-list-viewHmm, I think I’m doing this wrong:
[gc_list_view date_format=d.m.Y end_date=d.m.Y]
Can you help?
How you design and layout the system will depend on how you want to customize it. For a simple “start date – end date” format, the following could be used.
1. Specify the shortcut option hook_secret_key.
The password should be randomly generated. The date and time format is specified by date_format, where end_date is the date and time up to which data is to be retrieved.
[gc_list_view date_format=”d.m.Y” hook_secret_key=”example”]2. Add the following code to the end of your theme’s functions.php
Please back up this file before working on it so that you have a means of directly accessing functions.php, such as an FTP connection, in case of any problems.The “example” to the right of $hook_secret_key below should match the password for hook_secret_key, above.
add_filter( 'lvgc_each_output_data' , 'lvgc_each_output_data_add_enddate' , 10 , 2 ); function lvgc_each_output_data_add_enddate($out, $out_atts){ extract($out_atts); $hook_secret_key = 'example'; if ( isset($no_event_link) && !empty($no_event_link) ): $out = <<< ___EOF___ <p class='${html_tag_class}_item'><span class='${html_tag_class}_date'>$start_date_value - $end_date_value</span> $output_category_temp <span title="$gc_description_title">$gc_title</span> ___EOF___; else: $out = <<< ___EOF___ <p class='${html_tag_class}_item'><span class='${html_tag_class}_date'>$start_date_value - $end_date_value</span> $output_category_temp <a target="_blank" class='${html_tag_class}_link' href='$gc_link' title="$gc_description_title">$gc_title</a> ___EOF___; endif; if ( isset($view_location) && !empty($view_location) ): if( isset($view_location_name) && !empty($view_location_name) ): $location_header_name = $view_location_name; else: $location_header_name = __("Location:", $this->plugin_name); endif; $out .= <<< ___EOF___ <br/><span class='${html_tag_class}_location_head'>$location_header_name</span> <span class='${html_tag_class}_location'>$gc_location</span> ___EOF___; endif; $out .= <<< ___EOF___ </p> ___EOF___; return array('hook_secret_key'=>$hook_secret_key, 'data'=>$out); }
When I add your code to functions.php, and use [gc_list_view date_format=”d.m.Y” hook_secret_key=”example”] in my page, it displays exactly the same as before.
How would this add an end date to events?
And why is the key part necessary?
Just to be clear, I want the calendar to say:
10.03.2022 – 15.03.2022 Name of event
So it has to say when the event ends.
-
This reply was modified 2 years, 11 months ago by
leoniehoever.
Have you added code to your theme’s functions.php?
I understand your request clearly, so I implemented a new shortcode option “view_end_date” instead of using the hook.
Please update your plugin to 6.8 first. After that, you will set the following shortcode.
[gc_list_view date_format=“d.m.Y” view_end_date=”-“]
Great, that works, thank you.
There’s only one problem. When I add the event ‘Easter, no classes’ on April 18th, it displays on April 18th AND April 19th. Of course easter stops April 19th, but now it looks like Easter is still going on that day.
If you want to display event up to today, please set end_date=”now”.
That’s not what I meant.
When I have an event 14-18 April.
It displays on April 19th as well.
It should end on April 18th.Supported to fix the end date on the all-day events because the end date value getting Google Calendar API is the next day in the case of all-day events.
Please update the plugin to version 6.9.
Thank you, that is better.
Only now, it adds an end date to ALL events. So an event of one day will display:
18-04-2022 – 18-04-2022 Event title
So that’s a bit weird.
Your suggetion is good.
I changed to not show end date if view_end_date is set and the event period is only within a day.
Please update the plugin to version 6.9.2 and try it again.It’s perfect now.
Thank you so much for your work! -
This reply was modified 2 years, 11 months ago by
- The topic ‘End date’ is closed to new replies.