Support » Plugin: VS Event List » date in `single-event.php`

  • Resolved Marklcm

    (@marklcm)


    I am using single-event.php to 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]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Guido

    (@guido07111975)

    Hi,

    Don’t understand why you want this, because my plugin will display whole event (including meta, such as date and time) when using single or single-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-templates you can find the code that’s needed to determine which date is being used per event.

    Guido

    Thread Starter Marklcm

    (@marklcm)

    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 in vsel-templates and copied code to my single-event.php but had a problem.
    I will redo and see how it goes using lines 14 ā€“ 35.
    thanks

    Plugin Author Guido

    (@guido07111975)

    Hi,

    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-event so your custom CSS only applies to a single event.

    Guido

    Plugin Author Guido

    (@guido07111975)

    Hi again,

    In this thread I’ve pasted code to display the event date(s) in theme file single.

    Guido

    Thread Starter Marklcm

    (@marklcm)

    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

    • This reply was modified 3 years, 4 months ago by Marklcm.
    • This reply was modified 3 years, 4 months ago by Marklcm.
    • This reply was modified 3 years, 4 months ago by Marklcm.
    Plugin Author Guido

    (@guido07111975)

    Hi,

    First, thank you for your donation, I really appreciate it šŸ™‚

    You’re almost there, you forgot the %s parameter:

    
    $page_time_label = __( 'Time: %s', 'very-simple-event-list' );
    $page_location_label = __( 'Location: %s', 'very-simple-event-list' );
    

    Guido

    Thread Starter Marklcm

    (@marklcm)

    many thanks

    Plugin Author Guido

    (@guido07111975)

    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

    Thread Starter Marklcm

    (@marklcm)

    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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘date in `single-event.php`’ is closed to new replies.