From aa4761f42e03a1565f626911604b73642f2aaafb Mon Sep 17 00:00:00 2001 From: Fellan-91 Date: Thu, 18 Apr 2024 14:45:34 +0300 Subject: [PATCH] fixed the behavior of the "All" filters link when the gallery is set as the home page. (#203) --- classes/class-archive-mapping.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/class-archive-mapping.php b/classes/class-archive-mapping.php index 979caf05..934cd52a 100644 --- a/classes/class-archive-mapping.php +++ b/classes/class-archive-mapping.php @@ -503,6 +503,23 @@ public function add_filter_items( $terms, $vp_options ) { $link = str_replace( $changed_part_of_link, $base_page, $term['url'] ); $link = $this->convert_category_to_friendly_url( $link ); + /** + * When the portfolio archive page is set as the main page + * The filter with All the elements breaks + * A link of this type: mysite.com/portfolio/ + * Must be forced to this: mysite.com + */ + if ( + '*' === $term['filter'] && + (int) get_option( 'page_on_front' ) === (int) $this->archive_page + ) { + $portfolio_slug = self::get_portfolio_slug(); + + if ( ! empty( $portfolio_slug ) ) { + $link = str_replace( $portfolio_slug . '/', '', $link ); + } + } + $terms[ $key ]['url'] = $link; } }