Venues

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

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

    How can I show events from multiple venues?
    I use this code:

    $events = eo_get_events(array(
    ‘post_type’ => ‘event’,
    ‘numberposts’=>10,
    ‘event_start_after’=>’today’,
    ‘event-venue’ => ‘big-hall’,
    ‘showpastevents’=>true,
    ‘suppress_filters’ => false,
    ));

    I have tried different ways, without luck.
    Eirik

    Eirik Kyrkjeeide
    #10797

    Other question is how to list only categories that has active events. Not past events.
    Eirik

    Eirik Kyrkjeeide
    #10798

    Hi Eirik,

    Venues are taxonomy terms, so you can query events in multiple venues using the tax_query argument, with taxonomy set to event-venue. The WordPress codex has examples of the tax_query argument (note WP_Query() arguments can be used in eo_get_events().

    Getting the IDs of categories of events matching a query is not straightforward unfortunately. You could query all future events, and then loop through and pull out their categories, but that’s quite costly.

    A better, but more complicated way is to attack it directly with SQL. Please note I haven’t tested the code below, so there maybe mistakes, but it should point in you the right direction.

    $now = new DateTime();
    $sql = $wpdb->prepare("
      SELECT DISTINCT t.*
      FROM {$wpdb->prefix}_terms AS t
      INNER JOIN {$wpdb->prefix}_term_taxonomy AS tt  #Join the taxonomy table to terms...
      ON t.term_id = tt.term_id 
      JOIN {$wpdb->prefix}_term_relationships AS tr #Join posts to the term relationship table
      ON tr.term_taxonomy_id = tt.term_taxonomy_id
      JOIN {$wpdb->prefix}_posts AS p
      ON p.ID = tr.object_id
      JOIN {$wpdb->eo_events} AS ev
      ON p.ID = ev.post_id
      WHERE tt.taxonomy IN ('event-category')
      AND p.post_type = 'event'
      AND p.post_status = 'publish'
      AND ( ev.StartDate > %s OR (ev.StartDate = %s AND ev.StartTime > %s) )
      ORDER BY t.name ASC;",
      $now->format( 'Y-m-d' ),
      $now->format( 'Y-m-d' ),
      $now->format( 'H:i:s' )
    );
    $cats_with_upcoming_events = $wpdb->get_results( $sql );
    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.