• Resolved Jan

    (@krugmedien)


    Hi,
    is it possible to show all events ordered by date, but show featured events first?

    I found this code example in your documentation:
    https://wp-eventmanager.com/documentation/ordering-events-by-event-start-date-meta-key/

    Now I tried to add, that featured events are listed first.
    I tried this:

    function custom_event_manager_get_listings_args( $query_args ) {
      $query_args[ 'orderby' ] = array(
        'featured'         => 'DESC',
        'event_start_date' => 'ASC'
      );
      return $query_args;
    }
    add_filter( 'event_manager_get_listings_args', 'custom_event_manager_get_listings_args', 99 );
    
    function custom_get_event_listings_query_args( $query_args ) {
      $query_args[ 'meta_query' ][ 'featured' ] = array(
        'key'     => '_featured',
        'compare' => 'EXISTS'
      );
      $query_args[ 'meta_query' ][ 'event_start_date' ] = array(
        'key'     => '_event_start_date',
        'compare' => 'EXISTS'
      );
      return $query_args;
    }
    add_filter( 'get_event_listings_query_args', 'custom_get_event_listings_query_args', 99 );

    With this Code featured events are listed first, but all events are not ordered by date. :-/

    Thanks for your help!
    Jan

    • This topic was modified 4 years, 1 month ago by Jan.
Viewing 1 replies (of 1 total)
  • Thread Starter Jan

    (@krugmedien)

    Solved it on my own and updated my post with the solution. 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘ordered by date, but show featured events first’ is closed to new replies.