Combining category and venue queries

WordPress Event Management, Calendars & Registration Forums General Question Combining category and venue queries

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 7 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25980

    Hi Stephen,

    I’m trying to query events at certain venue with a certain category. I have both queries working independently but when I try to use them together I get no results every time. Here’s my code…

    $county = isset($_GET['county']) && $_GET['county']!== "-1" ? $_GET['county']:'';
     $category = isset($_GET['category']) && $_GET['category']!== "-1" ? $_GET['category']:'';
    
     $args = array( 
        'post_type' => 'event',     
        'event_start_before' => 'today'
      );
    
    // Alternate params to query category 
    // if( $category ) {
     //  $args['tax_query'] = array(
     //    array(
     //      'taxonomy' => 'event-category',
     //      'terms'    => $category
     //    ));
     // };
    
     if( $category ) {
      $args['event-category'] = 'slapstick';
     };
    
     if( $county ) {
      $args['venue_query'] = array(
        array(
          'key' => '_state',
          'value' => $county
        ));
     };
    
    $event_query = new WP_Query($args);
    
    Andrew Shankie
    #25983

    Hi Andrew,

    I’ve tested that, and it works for me. Are you sure that you’ve got events which are in both the county and category?

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