$series_id, 'post_type' => 'comic', 'post_status' => 'publish', 'posts_per_page' => $adjacent_limit, 'orderby' => 'publish_date', ); if ($collection_id > 0) { $adjacent_args['tax_query'] = array( array( 'taxonomy' => 'collections', 'field' => 'term_id', 'terms' => $collection_id, ), ); } $before_args = $after_args = $adjacent_args; $before_args['order'] = 'DESC'; $after_args['order'] = 'ASC'; $before_args['date_query'] = array( array( 'column' => 'publish_date', 'before' => $current_publish_date, 'inclusive' => true, ), ); $after_args['date_query'] = array( array( 'column' => 'publish_date', 'after' => $current_publish_date, 'inclusive' => false, ), ); $before_query = new WP_Query($before_args); $before_count = $before_query->post_count; $after_query = new WP_Query($after_args); $after_count = $after_query->post_count; $after_query->posts = array_reverse($after_query->posts); $overall_count = $before_count + $after_count; $merged_query = new WP_Query(); $merged_query->posts = array_merge($after_query->posts, $before_query->posts ); $merged_query->post_count = $overall_count; if ($carousel_order === 'DESC') { $merged_query->posts = array_reverse($merged_query->posts); } //echo $after_query->request; ?>