WordPress.org

Ready to get started?Download WordPress

Forums

Event Organiser
Do not display Event type in a Venue on a Specific day of the week (5 posts)

  1. CharliePM
    Member
    Posted 5 months ago #

    Hello world,
    Thanks for this beautiful plugin i'm using very often.
    I have a specific situation i can't resolve.
    I have a Agenda with 2 venues.
    We organise Shows and Exhibitions in both of them, however, one of the venue is closed on Sunday. So we don't have exhibition in this venue those days.

    On the archives-event page I display first the shows, with the main query then the exhibitions.
    So I have modified the main query to display every thing but the exhibition then I've made a custom query to display exhibitions.
    This query is working well but it does not react well with the calendar widget. When I click on a Sunday on the calendar, the exhibition is displayed even when the venue is closed.

    here is my main query modified in functions.php

    add_action('pre_get_posts','wpse50761_alter_query',15);
    
    function wpse50761_alter_query($query){
    
    $taxquery = array( array(
                             'taxonomy'=>'event-tag',
                             'operator' => 'NOT IN',
                             'field'=>'slug',
                             'terms'=>array('exposition')
                             ));
    
          if( $query->is_main_query() && is_post_type_archive('event') ){
    	$query->set('tax_query',$taxquery);
    	$query->set('order','desc');
          }
    }

    and this is my custom query in archives-event.php after the first loop

    //DISPLAY EXHIBITIONS
    
    $events = eo_get_events(
                         array(
               'numberposts' => 2,
               'offset' => 0,
               'event-tag' => 'exposition',
               'orderby' => 'eventstartdate',
               'order' => 'ASC',
               'showpastevents' => false,
               'event_start_before' => '',
               'event_start_after' => '',
               'event_end_before' => '',
               'event_end_after' => $todaysDate,
               'include' => '',
               'exclude' => '',
               'meta_key' => '',
               'meta_value' => '',
               'post_status' => 'publish',
    		   'group_events_by' => 'series',
                              ));
    
                  foreach ($events as $event){
    			$venue = eo_get_venue($event->ID);
    ... my exhibition post ...
    }

    I hope i'm clear enough. Please ask me if i'm not.
    Thanks you for your help.

    https://wordpress.org/plugins/event-organiser/

  2. Stephen Harris
    Member
    Plugin Author

    Posted 5 months ago #

    So when you click on a Sunday (e.g. 9th March), you land on that days' page and (normally) it shows events on that day. The 'day' page uses the template archive-event.php too. So I guess you probably don't want to include your custom query when a 'day' is being shown.

    You can use this function to determine if a 'day', 'month' or 'year' page is being shown: eo_is_event_archive()
    and the actual date via: eo_get_event_archive_date()


    On a side note, you have a query with $todaysDate - you don't have to pass an actual date to the argument, you can use relative dates (e.g. 'today') :).

  3. CharliePM
    Member
    Posted 5 months ago #

    Thank you for this anwser !
    I applied your method and it worked but I created a Frankenstein.
    I don't know how to simplify my nested if statement.
    The problem is that eo_get_event_archive_date need to be in a conditional eo_is_event-archive. So my result is vomplicated with duplicated code

    <?php foreach ($events as $event){
    	  if (eo_is_event_archive('day') ){
    	  $venue_id = eo_get_venue($event->ID);
    	   $jour = eo_get_event_archive_date ('l');
          if  (($jour == 'Dimanche' ) && ($venue_id == 6) ) { /*DO NOT DISPLAY ANYTHING */}
    else  {  ?>
          <article style="min-height:160px;"  <?php post_class('archives clearfix'); ?> id="">
            <header class="entry-header">
              <h1 class="entry-title"> <?php echo get_the_post_thumbnail($event->ID,array(120,160), array('style'=>'float:left;margin-right:20px;')); ?> <a href="<?php echo get_permalink($event->ID) ?>" rel="bookmark" title="<?php echo $event->post_title ?>"> <?php echo  $event->post_title ?></a> </h1>
              <div class="event-entry-meta">
              <div style="time">
                <?php   
    
    	_e('à ','eventorganiser'); ?>
                <strong> <a href="<?php eo_venue_link($venue_id); ?>" class="venue_link"> <?php echo  eo_get_venue_name($venue_id); ?></a></strong> </div>
            </header>
            <!-- Event excerpt -->
            <section class="entry-content">
              <p><?php echo $event->post_excerpt; ?> </p>
            </section>
          </article>
          <?php }
    	  }
     else {
     ?>
          <article style="min-height:160px;"  <?php post_class('archives clearfix'); ?> id="">
            <header class="entry-header">
              <h1 class="entry-title"> <?php echo get_the_post_thumbnail($event->ID,array(120,160), array('style'=>'float:left;margin-right:20px;')); ?> <a href="<?php echo get_permalink($event->ID) ?>" rel="bookmark" title="<?php echo $event->post_title ?>"> <?php echo  $event->post_title ?></a> </h1>
              <div class="event-entry-meta">
              <div style="time">
                <?php   
    
    	_e('à ','eventorganiser'); ?>
                <strong> <a href="<?php eo_venue_link($venue_id); ?>" class="venue_link"> <?php echo  eo_get_venue_name($venue_id); ?></a></strong> </div>
            </header>
            <!-- Event excerpt -->
            <section class="entry-content">
              <p><?php echo $event->post_excerpt; ?> </p>
            </section>
          </article>
          <?php wp_reset_postdata(); ?>
          <?php } /*END ELSE */?>
          <?php } /*END FOREACH */?>

    It's quite slow.

  4. Stephen Harris
    Member
    Plugin Author

    Posted 5 months ago #

    Looks fine, but so simplify it you could do:

    $venue_id = eo_get_venue($event->ID);
       if  ( 0 === eo_get_event_archive_date('w') && $venue_id == 6 ) {
          continue;
       }

    But I'm confused as to why it's necessary. If an event is not supposed to occur on a Sunday, then you can exclude that day. (Or have you set it up as a 'long' event, e.g. which starts on 8th March and finishes on the 15th)? In that example you might consider instead creating the event to be on the 8th and repeating every day until the 15th (except on Sundays). Even easier would be to repeat the event every week on every day except Sundays.

  5. CharliePM
    Member
    Posted 5 months ago #

    Thanks for the advice, i did not know the continue function.
    You are right. They are 2 exhibitions running on a few months.
    I have made a long event for each and I set "Répétition" as "Customised" and i picked up manualy the dates in the calendar "Inclure/Exclure des occurrences"
    And the weird thing, is that both venues are closed on Monday and were closed for Christmas. When both venues are closed, the calendar is put in grey and the day in not clickable. So it's fine.
    But when only one venue is closed, both exhibition shows.

    I have tried to change the settings to set "repeat every weeks" but when I update the article it does not make any change.
    This is why a had to trick it.

Reply

You must log in to post.

About this Plugin

About this Topic