Skip to content

Commit

Permalink
TMS-982: Fix exhibition-archive year-filters & search
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbi committed Oct 10, 2023
1 parent 3f1cb3f commit ede2fe9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- TMS-982: Fix exhibition-archive year-filters & search

## [1.9.2] - 2023-09-04

### Fixed
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 ede2fe9

Please sign in to comment.