stephenharris/Event-Organiser

Improved query handling

stephenharris opened this issue · 2 comments

This involves improving two distinct, but vaguely related, issues:

  1. Handling queries which are for (but not exclusively) events.
  2. Support all taxonomies 'out of the box' (i.e. support any taxonomy registered to the event post type.

Note for 1: Sorting should not be overridden unless the query is exclusively event type.

A work-around for 2. is:

add_action( 'pre_get_posts', 'my_event_taxonomy_query', 8 );
function my_event_taxonomy_query( $query ){

     if( $query->is_tax( 'my-event-taxonomy' ){
          $query->set( 'post_type', 'event' );
     }
}

This is perfect!

add_action( 'pre_get_posts', 'my_event_taxonomy_query', 8 );
function my_event_taxonomy_query( $query ){
     if($query->is_tax('my-event-taxonomy')){
          $query->set( 'post_type', 'event' );
     }
}

Won't be needed in 1.8 :).

Currently the post type has to be event - a query with post type set to array( 'event' ) or array( 'post', 'event' ) or any - would be ignored by the plug-in (so no dates are pulled). It's going to be a lot more flexible in 1.8.

I have working code on my local repo, will push it here tomorrow.