From a14ff4acebf635aa12d253926f9e91d190a2c762 Mon Sep 17 00:00:00 2001 From: Fellan-91 Date: Mon, 15 Apr 2024 14:49:54 +0300 Subject: [PATCH] fixed the behavior of the "All" filters link when the gallery is set as the home page. --- 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; } }