prev / next event link

This topic contains 2 replies, has 2 voices, and was last updated by  tmksr 9 years, 8 months ago.

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

    hi, iam looking for a solution to show the pre / next event like (the_post_navigation) in single.php.
    i found your post at WP Forum (https://wordpress.org/support/topic/how-do-you-add-previousnext-buttons-to-a-single-event)
    but I only want to show events that will happen in the same venue and are from the same category. so there is no overlapping or recurring. thanks ! great plugin so far!

    tmksr
    #17856

    So you just need to add a tax query to restrict the return events to those in the same category and venue:

    $next_event = eo_get_events( array(
       'post_not__in'      => array( get_the_ID() ),
       'event_start_after' => eo_get_the_start( 'Y-m-d H:i:s' ),
       'tax_query' => array(
        'relation' => 'AND',
          array(
            'taxonomy' => 'event-category',
            'field'    => 'term_id',
            'terms'    => wp_list_pluck( get_the_terms(get_the_ID(), 'event-category'), 'term_id' ),
            'operator' => 'IN',
          ),
          array(
            'taxonomy' => 'event-venue',
            'field'    => 'term_id',
            'terms'    => wp_list_pluck( get_the_terms(get_the_ID(), 'event-venue'), 'term_id' ),
            'operator' => 'IN',
          ),
       )
    ) );
    
    if( $next_event ){
       $permalink = get_permalink( $next_event[0] );
       printf( '<a href="%s">Next event</a>', $permalink );
    }
    
    Stephen Harris
    #17901

    works fine, thanks a lot!

    tmksr
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.