diff --git a/includes/admin.php b/includes/admin.php
index 348305a..72954d2 100644
--- a/includes/admin.php
+++ b/includes/admin.php
@@ -71,15 +71,6 @@ jQuery(document).ready(function() {
add_action('post_submitbox_misc_actions', 'add_to_post_status_dropdown');
-add_action('edit_form_after_title', function () {
- // Vérifie si on est sur le bon post type
- $screen = get_current_screen();
- if ($screen && $screen->post_type === 'artisans') {
- echo '
' . get_the_title() . '
';
- }
-});
-
-
// Ajouter un filtre pour afficher les posts avec le statut 'offline'
add_filter('views_edit-artisans', function ($views) {
global $wpdb;
diff --git a/includes/artisans.php b/includes/artisans.php
index 566136e..66b6503 100644
--- a/includes/artisans.php
+++ b/includes/artisans.php
@@ -54,3 +54,70 @@ function metiers_patrimoine_chantiers_post_updater($post_id)
wp_update_post($my_post);
}
add_action('acf/save_post', 'metiers_patrimoine_chantiers_post_updater', 20);
+
+
+
+/* ---------------------------
+CUSTOM CODE FOR TITLE
+---------------------------*/
+add_action('edit_form_after_title', function () {
+ // Vérifie si on est sur le bon post type
+ $screen = get_current_screen();
+ if ($screen && $screen->post_type === 'artisans') {
+ echo '' . get_the_title() . '
';
+ }
+});
+
+
+/* ---------------------------
+CUSTOM CHANTIER META BOX AT THE END OF THE PAGE
+---------------------------*/
+add_action('add_meta_boxes', function () {
+ // Ajout de la metabox uniquement pour le post type 'artisans'
+ add_meta_box(
+ 'admin_artisan_chantier_list', // ID de la metabox
+ 'Chantiers réalisé par l\'entreprise', // Titre de la metabox
+ 'render_custom_chantier_box_content', // Fonction de rendu
+ 'artisans', // Post type
+ 'normal', // Contexte
+ 'low' // Priorité
+ );
+});
+
+/**
+ * Fonction de rendu du contenu de la metabox.
+ */
+function render_custom_chantier_box_content($post)
+{
+
+ $args = array(
+ 'post_type' => '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 '';
+ while ($chantiers->have_posts()) {
+ $chantiers->the_post();
+ $chantier_name = get_field('chantier_name');
+ echo '-
' . $chantier_name . ' ';
+ }
+ echo '
';
+ } else {
+ echo 'Aucun chantier pour cette entreprise.
';
+ }
+}