FEATURE Handling archive pages for different post types

This commit is contained in:
Antoine M 2026-02-13 15:44:00 +01:00
parent 0ede759d7b
commit ed89f9f9f6
4 changed files with 217 additions and 9 deletions

View File

@ -9,6 +9,7 @@
'url' => get_stylesheet_directory_uri() . '/resources/img/covers/carhop-page-analyses-etudes-cover.svg', 'url' => get_stylesheet_directory_uri() . '/resources/img/covers/carhop-page-analyses-etudes-cover.svg',
'alt' => 'Revues' 'alt' => 'Revues'
), ),
'has_overlap' => true,
'background_style' => 'sliced', 'background_style' => 'sliced',
'cta' => array( 'cta' => array(
'title' => __('Trouver une publication', 'carhop'), 'title' => __('Trouver une publication', 'carhop'),
@ -16,22 +17,89 @@
) )
)); ?> )); ?>
<div class="latest-parutions">
<h2 class="latest-parutions__title title-small">Dernière parution</h2>
<?php get_template_part('template-parts/revues/revues-grid'); ?>
<!-- #### EXPLORE TAGS #### -->
<?php <?php
$block_content = '<!-- wp:dynamiques-blocks/explore-tags /-->'; $latest_analyse = get_posts(array(
echo do_blocks($block_content); 'posts_per_page' => 1, // Number of recent posts thumbnails to display
'post_status' => 'publish', // Show only the published posts
'post_type' => 'analyses-etudes',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => 'analyse',
),
),
));
$latest_etude = get_posts(array(
'posts_per_page' => 1, // Number of recent posts thumbnails to display
'post_status' => 'publish', // Show only the published posts
'post_type' => 'analyses-etudes',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => 'etude',
),
),
));
$recent_posts = array_merge($latest_analyse, $latest_etude);
?>
<?php foreach ($recent_posts as $post) : ?>
<?php
$type = get_the_terms($post->ID, 'type');
?>
<div class="post-card post-card--analyses-etudes">
<?php if (is_array($type) && !empty($type) && isset($type[0]->name)) : ?>
<div class="latest-parution__item">
<div class="content-meta">
<span class="content-meta__type content-meta__type--revue"><?php echo $type[0]->name; ?></span>
<p class="content-meta__revue-issue content-meta__revue-issue--green">
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
28
</p>
</div>
<?php endif; ?>
<a href="<?php echo get_the_permalink($post->ID); ?>">
<?php echo get_the_post_thumbnail($post->ID, 'medium'); ?>
<h3><?php echo get_the_title($post->ID); ?></h3>
</a>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- #### ANALYSES ET ETUDES POST GRID #### -->
<?php get_template_part('template-parts/analyses-etudes/analyses-etudes-grid'); ?>
<!-- #### SOUTENIR #### -->
<?php
$composition_id = 988;
$soutenir_content = get_post_field('post_content', $composition_id);
if ($soutenir_content) {
echo do_blocks($soutenir_content);
}
?> ?>
<!-- #### PROCHAINEMENT #### -->
<?php get_template_part('template-parts/components/decouvrez-prochainement'); ?>
<!-- #### INFOLETTRE #### --> <!-- #### INFOLETTRE #### -->
<?php get_template_part('template-parts/components/subscribe-infolettre'); ?> <?php
$composition_id = 992;
$_infolettre_content = get_post_field('post_content', $composition_id);
if ($_infolettre_content) {
echo do_blocks($_infolettre_content);
}
?>
</main> </main>
<?php <?php

50
archive-expositions.php Normal file
View File

@ -0,0 +1,50 @@
<?php get_header(); ?>
<?php
$current_post_type = get_post_type();
?>
<main id="content" class="site-content flex-grow">
<?php get_template_part('template-parts/expositions/archive-header'); ?>
<!-- #### LATEST PARUTIONS #### -->
<?php get_template_part('template-parts/components/archive/latest-parutions', null, array(
'post_amount' => 1,
'post_type' => 'expositions',
));
?>
<!-- #### ANALYSES ET ETUDES POST GRID #### -->
<?php get_template_part('template-parts/components/archive/post-grid', null, array(
'current_post_type' => 'expositions',
'post_amount' => -1,
'grid_title' => 'Trouver une exposition',
)); ?>
<!-- #### SOUTENIR #### -->
<?php
$composition_id = 988;
$soutenir_content = get_post_field('post_content', $composition_id);
if ($soutenir_content) {
echo do_blocks($soutenir_content);
}
?>
<!-- #### INFOLETTRE #### -->
<?php
$composition_id = 992;
$_infolettre_content = get_post_field('post_content', $composition_id);
if ($_infolettre_content) {
echo do_blocks($_infolettre_content);
}
?>
</main>
<?php
get_footer();

View File

@ -0,0 +1,51 @@
<?php get_header(); ?>
<?php
$current_post_type = get_post_type();
?>
<main id="content" class="site-content flex-grow">
<?php get_template_part('template-parts/outils-pedagogiques/archive-header'); ?>
<!-- #### LATEST PARUTIONS #### -->
<?php get_template_part('template-parts/components/archive/latest-parutions', null, array(
'post_amount' => $post_amount,
'post_type' => 'outils-pedagogiques',
));
?>
<!-- #### POST GRID #### -->
<?php get_template_part('template-parts/components/archive/post-grid', null, array(
'current_post_type' => 'outils-pedagogiques',
'post_amount' => -1,
'grid_title' => 'Trouver un outil pédagogique',
)); ?>
<!-- #### SOUTENIR #### -->
<?php
$composition_id = 988;
$soutenir_content = get_post_field('post_content', $composition_id);
if ($soutenir_content) {
echo do_blocks($soutenir_content);
}
?>
<!-- #### INFOLETTRE #### -->
<?php
$composition_id = 992;
$_infolettre_content = get_post_field('post_content', $composition_id);
if ($_infolettre_content) {
echo do_blocks($_infolettre_content);
}
?>
</main>
<?php
get_footer();

39
archive.php Normal file
View File

@ -0,0 +1,39 @@
<?php get_header(); ?>
<?php
$current_post_type = get_post_type();
?>
<main id="content" class="site-content flex-grow">
<?php if ($current_post_type === 'analyses-etudes') : ?>
<?php get_template_part('template-parts/analyses-etudes/archive-header'); ?>
<?php elseif ($current_post_type === 'expositions') : ?>
<?php get_template_part('template-parts/expositions/archive-header'); ?>
<?php endif; ?>
<?php get_template_part('template-parts/expositions/archive-latest-parutions', null, array()); ?>
<!-- #### SOUTENIR #### -->
<?php
$composition_id = 988;
$soutenir_content = get_post_field('post_content', $composition_id);
if ($soutenir_content) {
echo do_blocks($soutenir_content);
}
?>
<!-- #### INFOLETTRE #### -->
<?php
$composition_id = 992;
$_infolettre_content = get_post_field('post_content', $composition_id);
if ($_infolettre_content) {
echo do_blocks($_infolettre_content);
}
?>
</main>
<?php
get_footer();