Multiple eo_events Templates

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

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

    Hi Stephen,

    I want to have 2 differently formatted lists and so I created a custom template file for the Events Lists.

    While this method allows me to change the formatting and add in some extra PHP, I can have 1 template page that’s used for the shortcode.

    Is there any way I can pass an argument through to the template file so I can change the template based on an if statement. Or do you see any other way to accomplish this?

    This is the output after PHP

    Template 1

    <h2 style="text-align: center;font-size:50px;line-height:55px;"><?php the_field('event_organisation'); ?></h2>
    <h1 style="text-align: center;font-size:62px;line-height:67px;"><?php the_title(); ?></h1>
    <h3 style ="text-align: center;font-size:50px;line-height:55px;">Raum: "<?php echo $venue_name; ?>" <?php echo $floor; ?></h3>
    

    Template 2

    <h2 style="text-align: center;font-size:50px;line-height:55px;"><?php the_field('event_organisation'); ?></h2>
    <h1 style="text-align: center;font-size:62px;line-height:67px;"><?php the_title(); ?></h1>
    
    Omayr McAdam
    #19559

    Maybe an easier way is to create Page Templates within my theme that contain the loop within them, However I would need to tell the loop to only show events happening today.
    Thats the only actual argument I pass to the loop. so this might be an easier method.

    Your guidance is appreciated.

    Omayr McAdam
    #19573

    The template for the shortcodes if filtered by eventorganiser_event_list_loop, but there is no context there unless you rely on the global context (e.g. using WordPress’ functions to determine what page is being viewed – i.e. is_page()).

    But I think your latter suggestion is much more straightforward. To get events happening today you can use event_start/end_before/after attributes

      $events = eo_get_events( array(
           'showpastevents' => true,//toggle depending whether you want past events
           'event_start_after' => 'today', //this is inclusive          
           'event_start_before' => 'today', //this is inclusive
      ) );
    

    Strictly speaking the above is events which start today. But you can reconfigure that using event_end_after to show any events which might be running that day (e.g. they start yesterday, but finish tomorrow). More details can be found here: http://codex.wp-event-organiser.com/function-eo_get_events.html

    If you prefer to use WP_Query:

      $query = new WP_Query( array(
           'post_type' => 'event',
           'suppress_filters' => false,
           'showpastevents' => true,//toggle depending whether you want past events
           'event_start_after' => 'today', //this is inclusive          
           'event_start_before' => 'today', //this is inclusive
      ) );
    
    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.