<?php
$wrapper_attributes = get_block_wrapper_attributes(['class' => 'see-also alignfull']);
$title = $attributes['title'] ?? null;

$current_post_ID = $attributes['currentPostID'] ?? get_the_ID();
$current_tags = get_the_terms($current_post_ID, 'etiquettes');


$relate_topic_posts = get_posts(array(
	'post_type' => array('analyses-etudes', 'expositions', 'outils-pedagogiques'),
	'tax_query' => array(
		array(
			'taxonomy' => 'etiquettes',
			'field' => 'term_id',
			'terms' => wp_list_pluck($current_tags, 'term_id'),
		),
	),
	'posts_per_page' => 3,
	'post__not_in' => array($current_post_ID),
));

?>

<section <?php echo $wrapper_attributes; ?>>
	<div class="inner">
		<div class="see-also__titling">
			<h2 class="see-also__title title-small">Suggestions</h2>
			<h3 class="see-also__subtitle subtitle-big">Voir aussi <br /> sur ce sujet</h3>
		</div>
		<div class="post-list">
			<?php foreach ($relate_topic_posts as $post) : ?>
				<?php get_template_part('template-parts/components/cards/post-card', null, array('ID' => $post->ID, 'current_post_type' => $post->post_type)); ?>
			<?php endforeach; ?>
		</div>
	</div>
</section>