Write out end dates of multiple day reoccuring events

WordPress Event Management, Calendars & Registration Forums General Question Write out end dates of multiple day reoccuring events

This topic contains 7 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 6 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17461

    I have a 2-day event which reoccurs, lets say 1-2 oct 2015, then 2-3 nov 2015.and then 4-5 dec 2015.
    Event Details states
    “This event is running from 1 oct 2015 until 5 dec 2015. It next occurs on 2 nov 2015.”

    This is not really correct, I would like te eb abel to write out the individual end dates and have Event details stating:
    This event occurs
    1 oct 2015 – 2 oct 205
    3 nov 2015 – 4 nov 2015
    4 dec 2015 – 5 dec 2015

    (or even nicer would be 1-2 oct 2015, 3-4 nov adn so on.

    How do I acheve this, I can’t figure out how to access the individual end dates?

    Frank Dandenell
    #17463

    Think I figured this one out

    <?php eo_the_end($date_format); ?>
    

    That snippet writes out the individual end date, I hope 😉

    Frank Dandenell
    #17466

    Nope, it just takes the absolute last date, not the individual end date af an reoccuring event

    Frank Dandenell
    #17467

    Hi Frank,

    The default text is confusing for events with arbitrary dates – it was originally intended for ‘regularly’ recurring events with an implied structure to the dates.

    Default templates were intended to be just that, so you can over-ride them by copying the your theme (event-meta-single-event.php in this case), but I gather you probably know that anyway ;).

    eo_the_end() is indeed the correct function to use – it prints the end date of the specified occurrence. When this event is not specified (as in your example), it uses the ‘current occurrence’.

    What the ‘current occurrence’ is depends on the global value $post. In effect, if you’re using it outside a WP_Query loop, then you need to be explicit.

    In event-meta-event-single.php there is an example of such a loop which prints the start dates of the event – that could be modified to display the end dates too.

    Stephen Harris
    #17469

    I’m getting closer but I need php assistance. How do I do an if statement to check if eo_the_start is the same as eo_the_end and then… What I’m after is to check if start date and end date is same, just print start date. If end date differs – print end date after start date. The code below always prints start and end date, even for a one day event ( 1 nov 2015 – 1 nov 2015). How do I put in the correct if statement?

    <strong><?php _e('Upcoming Dates:','eventorganiser'); ?></strong> 
    <ul id="eo-upcoming-dates"> 
    <?php while( $upcoming->have_posts() ): $upcoming->the_post(); ?>
         <li> <?php eo_the_start($date_format) ?> - <?php eo_the_end($date_format) ?> </li> <?php endwhile; ?>
    </ul>
    
    • This reply was modified 9 years, 8 months ago by  Stephen Harris.
    Frank Dandenell
    #17472

    Hi Frank,

    This will be simpler in 3.0.0 there is a function designed to format a date range where appropriate (e.g. would print “1st-2nd November”, “1st November” and “1st November, 3pm-4pm” as appropriate).

    Until then, you can check if an occurrence starts and ends on the same day with:

     if ( eo_get_the_start( 'Ymd' ) == eo_get_the_end( 'Ymd' ) ){
          //same day
     } else {
         //not same day
     }
    

    eo_get_the_start() and eo_get_the_end() are almost identical to their counterparts without the _get except they return the formatted date rather than print it.

    E.g.

    <strong><?php _e('Upcoming Dates:','eventorganiser'); ?></strong> 
    
    <ul id="eo-upcoming-dates"> 
    <?php while( $upcoming->have_posts() ): $upcoming->the_post(); ?>
        <?php  if ( eo_get_the_start( 'Ymd' ) == eo_get_the_end( 'Ymd' ) ) { ?>
             <li> <?php eo_the_start($date_format) ?></li>          
        <?php } else { ?>
             <li> <?php eo_the_start($date_format) ?> - <?php eo_the_end($date_format) ?> </li>
        <?php } ?>
    <?php endwhile; ?>
    </ul>
    
    Stephen Harris
    #18709

    Hi, when is version 3.0 available, I would love to get my dates as “1-2 november 2015” instead of “1 november 2015 – 2 november 2015”.
    Some of my clients mistake it for being two separate one day events.
    Is it possible to have a snippet with just this function?
    Best regards, Frank

    Frank Dandenell
    #18711

    There’s no ETA although it has reached ‘private’ beta. If you wanted access to the beta version I’d be happy to provide it.

    Stephen Harris
Viewing 8 posts - 1 through 8 (of 8 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.