/* ========================================================== [villes-cuisinistes] — Version Strato / GeoDirectory ========================================================== */ function aakd_shortcode_villes_cuisinistes() { global $wpdb; $table = 'mls8_geodir_gd_place_detail'; // ✅ Préfixe Strato $region_slug = isset($_GET['regions']) ? sanitize_title($_GET['regions']) : ''; $ville_slug = isset($_GET['ville']) ? sanitize_title($_GET['ville']) : ''; $html = ''; /* === CAS 1 : page ville ================================= */ if (!empty($ville_slug)) { $ville_nom = ucwords(str_replace('-', ' ', $ville_slug)); // Récupère la région de cette ville $region = $wpdb->get_var($wpdb->prepare( "SELECT region_slug FROM $table WHERE city_slug=%s AND post_status='publish' LIMIT 1", $ville_slug )); // Nombre de cuisinistes dans la ville $nb_ville = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(post_id) FROM $table WHERE city_slug=%s AND post_status='publish'", $ville_slug )); $html .= "
"; $html .= "

Cuisinistes à $ville_nom

"; $html .= "

$nb_ville cuisiniste" . ($nb_ville > 1 ? 's' : '') . " dans la ville de $ville_nom.

"; // Si la ville appartient à une région, afficher toutes les villes de cette région if ($region) { $region_nom = ucwords(str_replace('-', ' ', $region)); $villes = $wpdb->get_results($wpdb->prepare( "SELECT city, city_slug, COUNT(post_id) AS nb FROM $table WHERE region_slug=%s AND post_status='publish' GROUP BY city HAVING nb > 0 ORDER BY nb DESC, city ASC LIMIT 100", $region )); if ($villes) { $html .= "

Autres villes de la région $region_nom :

"; } } $html .= "
"; return $html; } /* === CAS 2 : page région ================================ */ if (!empty($region_slug)) { $region_nom = ucwords(str_replace('-', ' ', $region_slug)); $villes = $wpdb->get_results($wpdb->prepare( "SELECT city, city_slug, COUNT(post_id) AS nb FROM $table WHERE region_slug=%s AND post_status='publish' GROUP BY city HAVING nb > 0 ORDER BY nb DESC, city ASC LIMIT 100", $region_slug )); if (empty($villes)) return "

Aucune ville trouvée pour $region_nom.

"; $html .= "
"; $html .= "

Villes et cuisinistes en $region_nom

"; $html .= "
"; return $html; } /* === CAS 3 : global (accueil / pied de page) ============ */ $villes = $wpdb->get_results(" SELECT city, city_slug, COUNT(post_id) AS nb FROM mls8_geodir_gd_place_detail WHERE post_status='publish' AND city<>'' AND city IS NOT NULL GROUP BY city HAVING nb > 0 ORDER BY nb DESC, city ASC LIMIT 120 "); if (empty($villes)) { return '

Aucune donnée disponible. Vérifie les fiches GeoDirectory.

'; } $html .= "
"; $html .= "

Cuisinistes par ville

"; $html .= "
"; return $html; } add_shortcode('villes-cuisinistes', 'aakd_shortcode_villes_cuisinistes'); https://kitchen-designer.org/page-sitemap.xml 2025-11-16T13:53:18+00:00 https://kitchen-designer.org/gd_place-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fitter-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_event-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_list-sitemap.xml 2023-01-02T14:16:37+00:00 https://kitchen-designer.org/category-sitemap.xml https://kitchen-designer.org/gd_event_tags-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_eventcategory-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_fittercategory-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_place_tags-sitemap.xml 2023-01-22T23:40:56+00:00 https://kitchen-designer.org/gd_placecategory-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_location_country-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_location_country_region-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_location_full-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_place_location_country-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fitter_location_country-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_event_location_country-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_place_location_country_region-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fitter_location_country_region-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_event_location_country_region-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_place_location_full-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fitter_location_full-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_event_location_full-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_placecategory_location_country-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fittercategory_location_country-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_eventcategory_location_country-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_placecategory_location_country_region-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fittercategory_location_country_region-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_eventcategory_location_country_region-sitemap.xml 2022-11-16T20:23:43+00:00 https://kitchen-designer.org/gd_placecategory_location_full-sitemap.xml 2025-11-09T06:42:53+00:00 https://kitchen-designer.org/gd_fittercategory_location_full-sitemap.xml 2025-10-20T23:22:14+00:00 https://kitchen-designer.org/gd_eventcategory_location_full-sitemap.xml 2022-11-16T20:23:43+00:00