<?php

function homegrade_brochure_post_title_updater($post_id)
{

	$my_post = array();
	$my_post['ID'] = $post_id;

	$brochureTaxonomy = get_the_terms($post_id, 'thematiques')[0];

	// write_log($brochureTaxonomy);

	if (get_post_type() == 'brochures') {

		$my_post['post_title'] = "";
		$my_post['post_title'] = $brochureTaxonomy->name;
	}


	wp_update_post($my_post);
}
add_action('acf/save_post', 'homegrade_brochure_post_title_updater', 20);
