Modifying shortcode-event-list.php

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11046

    Hi Stephen,
    I need to modify the shortcode-event-list.php template to output a simple list of events grouped by Month. I emailed you about this before. My attempt is below, however, it’s outputting the month before every list item. I only need to output the name of the month if it changes.
    Here’s the loop from the template that I’ve added code to – as ever, appreciate your help to get it right:

    <?php if( $eo_event_loop->have_posts() ): ?>

    <ul <?php echo $id; ?> class="<?php echo esc_attr($classes);?> eo-events-entry-list" > 
    
    
    
        <?php while( $eo_event_loop->have_posts() ): $eo_event_loop->the_post(); ?>
    
            <?php 
                //Generate HTML classes for this event
                $eo_event_classes = eo_get_event_classes(); 
    
                //For non-all-day events, include time format
                $format = ( eo_is_all_day() ? $date_format : $date_format.' '.$time_format );
            ?>
    
    
            <li class="<?php echo esc_attr(implode(' ',$eo_event_classes)); ?>" >
                <?php echo __('','eventorganiser') . ' '.eo_get_the_start('jS F'); ?> - " title="<?php the_title_attribute(); ?>" ><?php the_title(); ?>
            

    <?php
    if( !$previous_event_id || ( eo_get_the_start( 'Y-m', $previous_event_id, null, $previous_occurrence_id ) != eo_get_the_start( 'Y-m', $current_event_id, $current_occurrence_id ) ) ){
    echo eo_get_the_start('F');
    }
    ?>

        <?php endwhile; ?>
    Paul Oaten
    #11068

    any help with this one is appreciated 🙂

    Paul Oaten
    #11086

    You need to set the $previous_event_id and $previous_occurrence_id so that they they are set to the corresponding values of the previous event ($post->ID, $post->occurrence_id)(or false if you’re on the first event. ). Essentially you’re then looking for when the event’s month (as determined by Y-m) changes.

    (Just so you know, these forums use markdown. To write blocks of code, leave a blank line and indent by four spaces. Or just write out any code (without any escaping), highligh it and click the curly braces in the toolbar)

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