date in `single-event.php`
-
I am using
single-event.phpto display single events on a site using a child theme of the default twenty-seventeen theme.
Is there a way I can pull the date and time into this?The page I need help with: [log in to see the link]
-
Hi,
Don’t understand why you want this, because my plugin will display whole event (including meta, such as date and time) when using
singleorsingle-event.If you want to display date elsewhere inside that template file, it’s quite difficult because there are 3 different types of dates (start date, end date and a single date). Inside plugin file
vsel-templatesyou can find the code that’s needed to determine which date is being used per event.Guido
Hello Guido
I wanted to change the default blog post layout using a child theme of the default twenty seventeen theme. This has a full screen featured image and two columns, so I now have a smaller featured image, centered content and links to previous/next events removed.
I had had a look invsel-templatesand copied code to mysingle-event.phpbut had a problem.
I will redo and see how it goes using lines 14 β 35.
thanksHi,
If you want to use the code from file vsel-templates, you need to make some more adjustments. It’s not that easy as (kind of) mentioned before, unfortunately.
If you don’t want to change the display order of elements (for example time above date, instead of underneath) you can do this by using custom CSS only. Use the prefix
.single-eventso your custom CSS only applies to a single event.Guido
thank you,
I was nearly there.
this helped greatly.
The only thing I cannot seem to get to work is to display the Time and Location.
The labels are displaying.
You can see it[here](https://boyneburnettinlandrailtrail.org.au/event/rail-trail-meeting-at-monto/)<div class="event-date-time-location"> <?php // set date format if ( !empty($date_format_custom) ) { $date_format = $date_format_custom; } else { $date_format = get_option('date_format'); } // variables $page_start_date = get_post_meta( get_the_ID(), 'event-start-date', true ); $page_end_date = get_post_meta( get_the_ID(), 'event-date', true ); $page_time = get_post_meta( get_the_ID(), 'event-time', true ); $page_location = get_post_meta( get_the_ID(), 'event-location', true ); $page_date_label = __( 'Date: %s', 'very-simple-event-list' ); $page_start_label = __( 'Start date: %s', 'very-simple-event-list' ); $page_end_label = __( 'End date: %s', 'very-simple-event-list' ); $page_time_label = __( 'Time:', 'very-simple-event-list' ); $page_location_label = __( 'Location:', 'very-simple-event-list' ); // display date if ( empty($page_start_date) || empty($page_end_date) || ($page_start_date > $page_end_date) ) { echo '<p class="p-event-date-time-location">' . esc_attr__( 'Error: please reset date', 'very-simple-event-list' ) . '</p>'; } elseif ($page_end_date > $page_start_date) { echo '<p class="p-event-date-time-location">'; echo sprintf(esc_attr($page_start_label), '<span>'.date_i18n( esc_attr($date_format), esc_attr($page_start_date) ).'</span>' ); echo '</p>'; echo '<p class="p-event-date-time-location">'; echo sprintf(esc_attr($page_end_label), '<span>'.date_i18n( esc_attr($date_format), esc_attr($page_end_date) ).'</span>' ); echo '</p>'; } elseif ($page_end_date == $page_start_date) { echo '<p class="p-event-date-time-location">'; echo sprintf(esc_attr($page_date_label), '<span>'.date_i18n( esc_attr($date_format), esc_attr($page_end_date) ).'</span>' ); echo '</p>'; } if(!empty($page_time)) { echo '<p class="p-event-date-time-location">'; echo sprintf(esc_attr($page_time_label), '<span>'.esc_attr($page_time).'</span>' ); echo '</p>'; } if(!empty($page_location)) { echo '<p class="p-event-date-time-location">'; echo sprintf(esc_attr($page_location_label), '<span>'.esc_attr($page_location).'</span>' ); echo '</p>'; } ?> </div><!-- .event-date-time-location -->BTW I visited your Paypal, only coffee, but thank you
Hi,
First, thank you for your donation, I really appreciate it π
You’re almost there, you forgot the
%sparameter:$page_time_label = __( 'Time: %s', 'very-simple-event-list' ); $page_location_label = __( 'Location: %s', 'very-simple-event-list' );Guido
many thanks
But I think this was also possible by using custom CSS only: make width of event and info section 100%, hide the event image, and you are done. Or am I missing something?
Guido
I remember trying all css, it was a while back, but the featured image size messed it up from memory
this is doing everything, so is all good
Mark
The topic ‘date in `single-event.php`’ is closed to new replies.