FIX optimizing post name query and adress translations

This commit is contained in:
Nonimart 2025-08-05 14:21:52 +02:00
parent 354a3ac83f
commit b4a741391d

View File

@ -1,17 +1,18 @@
<?php <?php
// global $post;
$postID = $args['post_ID']; $postID = $args['post_ID'];
$post = get_post($postID); // global $post;
// $post = get_post($postID);
// $post_name = $post->post_name;
$post_name = get_post_field('post_name', $postID);
$current_lang = apply_filters('wpml_current_language', null); $current_lang = apply_filters('wpml_current_language', null);
$post_thumbnail = get_the_post_thumbnail($postID, 'full', array('class' => 'card-artisans__thumbnail card-post__thumbnail')) ?? null; $post_thumbnail = get_the_post_thumbnail($postID, 'full', array('class' => 'card-artisans__thumbnail card-post__thumbnail')) ?? null;
$postDefautlThumbnail = get_stylesheet_directory_uri() . '/resources/img/illustrations/Homegrade_resultats-filtres.svg'; $postDefautlThumbnail = get_stylesheet_directory_uri() . '/resources/img/illustrations/Homegrade_resultats-filtres.svg';
$post_title = $args['post_title']; $post_title = $args['post_title'];
$post_permalink = get_the_permalink($postID); $post_permalink = get_the_permalink($postID);
$artisans_clean_url = get_home_url(null, '/') . 'artisans/' . $post->post_name; $artisans_clean_url = get_home_url(null, '/') . 'artisans/' . $post_name;
$company_members = get_field('company_members', $postID); $company_members = get_field('company_members', $postID);
$currentTaxonomy = $args['current_taxonomy']; $currentTaxonomy = $args['current_taxonomy'];
@ -28,7 +29,7 @@ $email = get_field('email', $postID);
$website = get_field('website', $postID); $website = get_field('website', $postID);
$adresse = get_field('adresse', $postID); $adresse = get_field('adresse', $postID);
$translated_city = translate_city_name($adresse['city'], $current_lang); $translated_city = isset($adresse['city']) ? translate_city_name($adresse['city'], $current_lang) : '';
$cover_image = get_field('artisan_cover', $postID); $cover_image = get_field('artisan_cover', $postID);
@ -66,7 +67,7 @@ $cover_image = get_field('artisan_cover', $postID);
<?php if ($adresse): ?> <?php if ($adresse): ?>
<p class="card-artisans__adresse"> <p class="card-artisans__adresse">
<?= ($adresse['post_code'] ?? '') . ' ' . ($adresse['city'] ?? '') ?> <?= ($adresse['post_code'] ?? '') . ' ' . ($translated_city) ?>
</p> </p>
<?php endif; ?> <?php endif; ?>