homegrade_theme_production/single-post.php

99 lines
3.2 KiB
PHP

<?php
get_header();
$args = array(
'meta_key' => '_wp_page_template',
'meta_value' => "template-archive-news.php"
);
$relatedPageTemplatePage = get_pages($args) ? get_pages($args)[0] : null;
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="single-post-container single-post-container--news">
<?php /* --------
BREADCRUMB
---------------*/ ?>
<nav class="breadcrumbs_navigation" aria-label="<?php echo __("Vous êtes ici", "homegrade-theme__texte-fonctionnel") ?>">
<ol>
<li>
<a href="<?php echo home_url() ?>" title="<?php echo __("Accueil", "homegrade-theme__texte-fonctionnel") ?>">
<img src="<?php echo get_template_directory_uri() . "/resources/img/pictogrammes/icon_house_dark.svg" ?>" alt="">
</a>
</li>
<li>
<a href="<?php echo get_the_permalink($relatedPageTemplatePage) ?>">
<?php echo __("News", "homegrade-theme__texte-fonctionnel") ?>
</a>
</li>
<li>
<a href="<?php echo get_the_permalink(get_the_id()) ?>" aria-current='location'>
<?php echo get_the_title(get_the_id()) ?>
</a>
</li>
</ol>
</nav>
<div class="post-news-page-container">
<?php /* --------
HEADING BOX
---------------*/ ?>
<?php
get_template_part("template-components/heading-box--news", null, array(
"news_type" => get_the_terms(get_the_ID(), 'news_type'),
"title" => get_the_title(),
"thumbnail" => get_the_post_thumbnail(get_the_ID(), "full", array('class' => 'heading-box--news__thumbnail')),
"published" => get_the_date()
));
?>
<article class="entry-content single-news-editor-content">
<?php
the_content();
?>
</article>
<!-- PREVIOUS / NEXT ARTICLES -->
<div class="previous-next-posts">
<?php
$prev_post = get_previous_post() ?? null;
$next_post = get_next_post() ?? null;
$prev_thumbnail_url = get_the_post_thumbnail_url($prev_post, 'thumbnail');
$next_thumbnail_url = get_the_post_thumbnail_url($next_post, 'thumbnail');
?>
<?php if ($next_post) : ?>
<a class="previous-next-posts__next" href="<?php echo get_the_permalink($next_post->ID) ?>">
<div class="previous-next-posts__link-content">
<p class="post_denomination"><?php echo __("News suivante ", "homegrade-theme__texte-fonctionnel") ?></p>
<p class="post_title"><?php echo $next_post->post_title ?></p>
</div>
<img class="post_thumbnail" src="<?php echo $next_thumbnail_url ?>" alt="">
</a>
<?php endif; ?>
<?php if ($prev_post) : ?>
<a class="previous-next-posts__previous" href="<?php echo get_the_permalink($prev_post->ID) ?>">
<img class="post_thumbnail" src="<?php echo $prev_thumbnail_url ?>" alt="">
<div class="previous-next-posts__link-content">
<p class="post_denomination"><?php echo __("News précédente ", "homegrade-theme__texte-fonctionnel") ?></p>
<p class="post_title"><?php echo $prev_post->post_title ?></p>
</div>
</a>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php
get_footer();