Get All Occurrences/Events from Category

WordPress Event Management, Calendars & Registration Forums General Question Get All Occurrences/Events from Category

This topic contains 3 replies, has 3 voices, and was last updated by  Stephen Harris 8 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8604

    I cannot for the life of me figure out why I can’t get the start date for each occurence. My current code pulls the start date for the first occurrence–I ned the output to show the start date for each occurence of each event in a category.

    <?php
         $events = eo_get_events(array(
             'numberposts'=>-1,
             'tax_query'    => array(
                array(
                    'taxonomy'  => 'event-category',
                    'field'     => 'slug',
                    'terms'     => 'events'
                )
            )
         ));
        if($events):
            foreach ($events as $event):
                setup_postdata( $event );
                $startdate = eo_get_the_start('M j', $event->ID,null,$event->occurrence_id);
                echo $startdate; ?>
            endforeach;
        endif;
        wp_reset_query(); ?>

    But this just gets the start date of the first occurrence. I’ve tried using eo_get_current_occurrence_of() and some other attempts using posts to the forums, but nothing returns the current occurrence’s start date.

    Help?

    Brent Barkley
    #8620

    Hi Brent,

    In the plug-in’s settings are you grouping occurrences? If so, that will only get the next occurrence matching the query. Maybe try:

     $events = eo_get_events(array(
         'numberposts'=>-1,
         'group_occurrences_by' => 'occurrence',
         'tax_query'    => array(
            array(
                'taxonomy'  => 'event-category',
                'field'     => 'slug',
                'terms'     => 'events'
            )
        )
     ));

    Otherwise it looks good to me (though you don’t need the wp_reset_query() or setup_postdata() when using eo_get_events()).

    Let me know if the above helps or not, and if it doesn’t I can debug this is a bit further.

    Stephen Harris
    #24155

    Hi Stephen,

    I would like to display list of events grouped by category. A perfect example of how this is done can be found here:

    http://www.acuitytraining.co.uk/dates-prices/

    Any help offered will be appreciated. Also, if sharing code snippet, please include the file name and location within file where the snippet can be embedded, as I have noticed that the code snippets you share do not necessarily have this information.

    Bond Nwonye
    #24195

    Hi Bond,

    Unless editing a template file, all custom scripts should go in a utility plugin (although theme’s functions.php will also work).

    Would this event list be rendered by the event list shortcode?

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