Support

Home Forums Event Espresso Premium Listing unique events with EventListQuery

Listing unique events with EventListQuery

Posted: December 13, 2017 at 3:48 pm

Viewing 4 reply threads


Austin Ginder

December 13, 2017 at 3:48 pm

I’m using EE_Event_List_Query however as explained here was having expired events show up. As recommended I replaced EE_Event_List_Query with EventEspresso\core\domain\services\wp_queries\EventListQuery however now the events are listing their corresponding tickets as separate likes not just the main event as shown here. How can I get EventListQuery to also list out the unique events. Here is the code I’m using.

<?php 

$atts = array(
'title'         => NULL,
'limit'         => 5,
'css_class'     => NULL,
'show_expired'  => FALSE,
'month'         => NULL,
'category_slug' => NULL,
'order_by'      => 'start_date',
'sort'          => 'ASC'
);
// run the event query
global $wp_query;
$wp_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $atts );
if (have_posts()) : ?>
<?php while (have_posts()) : the_post();
  $n++;
if ($n === 1 && !featured_event_override) :
  // were technically only showing the first one here
  $event_img_src = wp_get_attachment_image_src(  get_post_thumbnail_id($post->ID), $size='rectangle');
  $event_img_src = get_the_post_thumbnail($post_id) != '' ? $event_img_src[0] : $event_img_src_backup;
?>
  <h5>Coming Up Next:</h5>
  <a href="<?php the_permalink(); ?>" class="next">
    <h6><?php the_title(); ?></h6>
    <span><?php echo espresso_event_date(); ?></span>
  </a>
  <h5>More Events</h5>
  <ul>
<?php else : ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span><?php echo espresso_event_date(); ?></span></a></li>
<?php
endif;
endwhile;
else:
?>
<li>No Upcoming Events</li>
<?php
  endif;
// now reset the query and postdata
wp_reset_query();
wp_reset_postdata();

?>


Josh

  • Support Staff

December 13, 2017 at 4:13 pm

Hi Austin,

now the events are listing their corresponding tickets as separate likes not just the main event as shown here

Do you mean separate date times? If so you can’t use and EventListQuery to loop through date times. You’ll need to do a custom Datetime query instead.


Austin Ginder

December 13, 2017 at 4:19 pm

Check it out here: http://blackrockretre.staging.wpengine.com/. The first event is correct: http://blackrockretre.staging.wpengine.com/events/escape-room-dec-17-22/ however the rest are all related to the first and should not be shown:


Josh

  • Support Staff

December 13, 2017 at 4:48 pm

Do you have some code in place that makes it so those other events “related” and then some other code in place that make it so they’re not shown? The EventListQuery doesn’t have either of those features.


Austin Ginder

December 14, 2017 at 6:34 am

After some more digging it would appear this was a simple matter of bad user input. There were apparently multiple events using the same name with tickets being sold on similar timeframes. I wrongly assuming they were grouped when they were not. Thanks for your tip about using a custom Datetime query.

Viewing 4 reply threads

The support post ‘Listing unique events with EventListQuery’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso