Hi,
I saw on the codex this:
eo_format_datetime( $datetime, $format = 'd-m-Y' )
How would I set this up in this unordered list to check the condition if it exists, then display the range of date when the event happens and when it ends?
<ul class="eo-event-meta">
// I don't need eo_recurs bc it's only a one day event
<?php if ( //code here to check if datetime exists// ) { ?>
<?php echo eo_format_datetime( $datetime, $format = 'd-m-Y' );?>:
<?php } ?>
Webmaster CCC
How would I set this up in this unordered list to check the condition if it exists
An event always has a start and end date, so there’s no need to check if these exist.
To format the range of the start and end datetime I would recommend using eo_format_event_occurrence()
. See http://codex.wp-event-organiser.com/function-eo_format_event_occurrence.html
You could use it as follows in your single-event.php
or event-meta-single-event.php
:
$occurrences = eo_get_the_occurrences_of(); //This should be array of one element for you
$occurrence_id = (int) key($array); //we're just grabbing an occurrence ID
echo eo_format_event_occurrence( get_the_ID(), $occurrence_id );
This will, by default, use your site’ss date/time format, but display the start and end date time as range.
Stephen Harris
Thank you I tried this and it works as well:
<?php if ( ! eo_recurs() ) { ?>
<!-- Single event -->
<?php _e('Start:', 'eventorganiser') ;?> <?php eo_the_start('F jS Y g:ia'); ?>
<?php _e('End:', 'eventorganiser') ;?> <?php eo_the_end('F jS Y g:ia'); ?>
<?php } ?>
The issue is, when the user clicks on all day. The Start and End time displays as:
Start: May 1st 2017 12:00am
End: May 1st 2017 11:59pm
I would like to have the condition for it to say : All Day
So I’m thinking something like this (pseudocode here):
If ( user checks on all day box in the fes form) {
Time: All Day
Else {
<!-- Single event -->
<?php _e('Start:', 'eventorganiser') ;?> <?php eo_the_start('F jS Y g:ia'); ?>
<?php _e('End:', 'eventorganiser') ;?> <?php eo_the_end('F jS Y g:ia'); ?>
<?php } ?>
}
I can’t find a query on the codex for the all day check box.
Webmaster CCC
You can replace 'F jS Y g:ia'
with:
eo_get_event_datetime_format( get_the_ID(), 'F jS Y', 'g:ia' )
Stephen Harris