diff --git a/functions.php b/functions.php index 049379d..4b84d2a 100644 --- a/functions.php +++ b/functions.php @@ -6,6 +6,7 @@ require_once(__DIR__ . '/includes/errorlog.php'); require_once(__DIR__ . '/includes/init.php'); require_once(__DIR__ . '/includes/post_types.php'); require_once(__DIR__ . '/includes/artisans.php'); +require_once(__DIR__ . '/includes/chantiers.php'); require_once(__DIR__ . '/includes/admin.php'); require_once(__DIR__ . '/includes/taxonomy.php'); require_once(__DIR__ . '/includes/api.php'); diff --git a/includes/chantiers.php b/includes/chantiers.php new file mode 100644 index 0000000..78e046b --- /dev/null +++ b/includes/chantiers.php @@ -0,0 +1,72 @@ + 'chantiers', + 'posts_per_page' => -1, + 'post_status' => 'publish', + 'meta_query' => array( + array( + 'key' => 'artisan', + 'value' => $post->ID, + 'compare' => '=', + ), + ), + ); + + $chantiers = new WP_Query($args); + + + // Afficher les chantiers + + if ($chantiers->have_posts()) { + + echo ''; + } else { + echo '

Ce chantier n\'est relié à aucun artisan

'; + } +} + + +add_action('acf/render_field', function ($field) { + // Vérifiez si le champ est celui que vous voulez personnaliser + if ($field['key'] === 'field_6719065f58122') { + if (did_action('acf/render_field/key=field_6719065f58122') % 2 === 0) { + return; + } + $field['rendered'] = true; + + $linked_post_id = get_field($field['key']); + + if ($linked_post_id) { + $edit_link = get_edit_post_link($linked_post_id); + echo ' Voir la fiche de l\'artisan '; + } + } +}, 10, 1);