From cd5d99a45c9d0cfe508aeeca5ef55ccb2b09551c Mon Sep 17 00:00:00 2001 From: Nonimart Date: Mon, 1 Sep 2025 17:11:05 +0200 Subject: [PATCH] FEATURE changing default taxonomy when not passed to the component --- includes/api.php | 5 +++-- template-components/artisans/card-artisans-search.php | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/api.php b/includes/api.php index ca92526..5335988 100644 --- a/includes/api.php +++ b/includes/api.php @@ -19,12 +19,13 @@ function build_search_artisan_posts_cards($request) $currentLanguage = esc_html($request->get_param('current-page-language')) ?? 'fr'; $previousActivePage = esc_html($request->get_param('active-page')) ?? 1; $postsPerPage = esc_html($request->get_param('posts-per-page')) ?? 12; - $taxonomy = esc_html($request->get_param('taxonomy')) ?? 'metiers'; + $taxonomy = esc_html($request->get_param('taxonomy')); + $taxonomy = empty($taxonomy) ? null : $taxonomy; + $localisation = esc_html($request->get_param('localisation')) ?? null; $StringifiedTaxonomyIds = esc_html($request->get_param('taxonomy-ids')) ?? null; do_action('wpml_switch_language', $currentLanguage); - // $lang = apply_filters('wpml_current_language', null); $taxonomyIds = explode(',', $StringifiedTaxonomyIds); $taxonomyIds = array_map('intval', $taxonomyIds); $search_value = sanitize_text_field($request->get_param('search')) ?? null; diff --git a/template-components/artisans/card-artisans-search.php b/template-components/artisans/card-artisans-search.php index eff1fdc..e4f4605 100644 --- a/template-components/artisans/card-artisans-search.php +++ b/template-components/artisans/card-artisans-search.php @@ -1,8 +1,5 @@ post_name; $post_name = get_post_field('post_name', $postID); $current_lang = apply_filters('wpml_current_language', null); @@ -16,7 +13,7 @@ $artisans_clean_url = get_site_url() . '/' . $lang_extension . 'artisans/' . $po $company_members = get_field('company_members', $postID); -$currentTaxonomy = $args['current_taxonomy']; +$currentTaxonomy = $args['current_taxonomy'] ?? 'elementsbatiments'; $taxonomySortedTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms_organised_by_parent('elementsbatiments', $postID) : get_the_terms_organised_by_parent('metiers', $postID);