FEATURE Refactoring and optimizing functionnal behaviour
This commit is contained in:
parent
435eb4f218
commit
86fd29864c
32
template-parts/authors/authors-list.php
Normal file
32
template-parts/authors/authors-list.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
$postId = $args['postId'];
|
||||
$isArticle = is_singular('articles');
|
||||
$componentTitle = $isArticle ? 'Auteur·e·s de l\'article' : 'Auteur·e·s de la revue';
|
||||
$articleTitle = get_the_title($postId);
|
||||
$authors = [];
|
||||
|
||||
if ($isArticle) {
|
||||
$authors = get_field('authors', $postId);
|
||||
} else {
|
||||
$authors = getRevueAuthors($postId);
|
||||
}
|
||||
|
||||
if (empty($authors)) return;
|
||||
|
||||
|
||||
?>
|
||||
<section class="revue-authors-list">
|
||||
<h3 class="revue-authors-list__title"><?php echo $componentTitle; ?></h3>
|
||||
<?php if ($articleTitle) : ?>
|
||||
<p class="revue-authors-list__article-title"><?php echo $articleTitle; ?></p>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($authors as $authorID) : ?>
|
||||
<?php get_template_part(
|
||||
'template-parts/authors/card-author',
|
||||
null,
|
||||
array(
|
||||
'ID' => $authorID,
|
||||
)
|
||||
); ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
$revueID = $args['revueID'];
|
||||
$authors = getRevueAuthors($revueID);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<section class="revue-authors-list">
|
||||
<h3 class="revue-authors-list__title">Auteur·e·s de la revue</h3>
|
||||
<?php foreach ($authors as $authorID) : ?>
|
||||
<?php get_template_part(
|
||||
'template-parts/authors/card-author',
|
||||
null,
|
||||
array(
|
||||
'ID' => $authorID,
|
||||
)
|
||||
); ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
Loading…
Reference in New Issue
Block a user