displaying dates as 1-2 nov 2015

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 9 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #19317

    Hi, I thought I mastered the art of displaying dates as “1-2 november 2015”. The shortcode below does this. But when I have a 1-day event it displays “1-1 november 2015” Please help me a find a way out of this. This is just a simple list of all upcoming events.

    [eo_events]<strong><a href="%event_url%">%event_title%</a></strong> %start{j}%-%end{j}% %start{M}% %end{Y}% <a href="%event_url%">Läs mer och boka här.</a>
    [/eo_events]
    

    //Frank

    Frank Dandenell
    #19349

    Hi Frank,

    Unfortunately adapting the date format according to the start/end format is not possible using the placeholders. You’d need to replace the above with just [eo_events] and then edit the event list shortcode template (you can find it in event-organiser/templates/event-list-shortcode.php.

    You can then format the date accordingly:

     $start_format = 'j M Y';
     $end_format = false;
    
     if ( eo_get_the_start( 'Ymd' ) != eo_get_the_start( 'Ymd' ) ) {
          //Event starts and ends on different dates
          $start_format = 'j';
          $start_format = '- j M Y';
     }
    
    //Print start date
    eo_the_start( $start_format );
    
    if ( $end_format ) {
        //If end date is different from start date, print end date.
        eo_the_end( $end_format );
    } 
    

    You could do further checks in case the event spans across a month or year, but I’ll leave you to make those adjustments.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 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.