add_action('save_post', function($post_id) {
if (wp_is_post_revision($post_id) || defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
// Get tag IDs from the post (custom "tags" taxonomy)
$post_tags = wp_get_object_terms($post_id, 'tags', ['fields' => 'ids']);
if (empty($post_tags)) return;
// Get all dossier terms
$dossier_terms = get_terms([
'taxonomy' => 'dossier',
'hide_empty' => false,
]);
$dossiers_to_assign = [];
foreach ($dossier_terms as $dossier) {
$related_tags = get_field('tags_dossier', 'dossier_' . $dossier->term_id);
if (!$related_tags) continue;
// Get tag IDs assigned to this dossier
$related_tag_ids = wp_list_pluck($related_tags, 'term_id');
// If any match post's tags, assign this dossier
if (array_intersect($post_tags, $related_tag_ids)) {
$dossiers_to_assign[] = $dossier->term_id;
}
}
if (!empty($dossiers_to_assign)) {
// Add related dossiers without removing existing ones
wp_set_object_terms($post_id, $dossiers_to_assign, 'dossier', true);
}
});
» Vereniging Bouw- & Woningtoezicht Nederland
De Vereniging BWT Nederland is een beroepsvereniging voor gemeenten, organisaties en personen die actief zijn in of betrokken zijn bij het bouw- en woningtoezicht door gemeenten.