Skip to content

Commit

Permalink
Merge pull request #165 from devgeniem/TMS-982
Browse files Browse the repository at this point in the history
TMS-982: Fix exhibition-archive year-filters & search
  • Loading branch information
eebbi authored Oct 11, 2023
2 parents 0662579 + c85c33a commit 6eb1dbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- TMS-982: Fix exhibition-archive year-filters & search
- TMS-936: Image carousel accessibility fixes

## [1.9.2] - 2023-09-04
Expand Down
17 changes: 12 additions & 5 deletions models/archive-exhibition.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,19 @@ public function results() {
$upcoming_exhibitions = $this->results->upcoming;

$unfiltered_past_exhibitions = array_filter( $this->results->all, [ $this, 'is_past' ] );
$past_exhibitions = $wp_query->posts;
$this->results->past = $past_exhibitions;
$past_exhibitions = array_filter( $wp_query->posts, [ $this, 'is_past' ] );
$this->results->past = $unfiltered_past_exhibitions;

$results = $is_past_archive ? $unfiltered_past_exhibitions : $upcoming_exhibitions;
$results = $is_past_archive ? $past_exhibitions : $upcoming_exhibitions;
$this->set_pagination_data( count( $results ), $per_page );

// Use past exhibitions pagination data when archive search is used
$found_posts = $wp_query->found_posts;
if ( ( self::get_search_query_var() || self::get_year_query_var() ) && $is_past_archive ) {
$this->set_pagination_data( $found_posts, $per_page );
$results = $past_exhibitions;
}

return [
'result_count' => count( $current_exhibitions ),
'past_results_count' => count( $unfiltered_past_exhibitions ),
Expand Down Expand Up @@ -375,8 +382,8 @@ public function years() {
*/
protected function reorder_main_exhibitions( $items ) {

// Return original $items array if search or year filter is used
if ( self::get_search_query_var() || self::get_year_query_var() ) {
// Return original $items array if search or year filter is used, or if page is past archive
if ( self::get_search_query_var() || self::get_year_query_var() || self::is_past_archive() ) {
return $items;
}

Expand Down

0 comments on commit 6eb1dbb

Please sign in to comment.