REFACTORING
This commit is contained in:
parent
d91f7c46c8
commit
0468c1704a
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
$postId = $args['postId'] ?? get_the_ID();
|
||||
$authors = get_field('authors', $postId);
|
||||
$isArticle = is_singular('articles');
|
||||
|
||||
if ($isArticle) {
|
||||
$authors = get_field('authors', $postId);
|
||||
} else {
|
||||
$authors = getRevueAuthors($postId);
|
||||
}
|
||||
if (empty($authors)) return;
|
||||
|
||||
|
||||
// Construire une meta_query avec OR pour chaque auteur
|
||||
$meta_query = array('relation' => 'OR');
|
||||
foreach ($authors as $author_id) {
|
||||
$meta_query[] = array(
|
||||
'key' => 'authors',
|
||||
'value' => '"' . $author_id . '"', // Recherche la valeur sérialisée
|
||||
'compare' => 'LIKE'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$authorsLastPosts = get_posts(array(
|
||||
'post_type' => $isArticle ? 'articles' : 'revues',
|
||||
'posts_per_page' => 6,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'meta_query' => $meta_query,
|
||||
));
|
||||
|
||||
if (empty($authorsLastPosts) || count($authorsLastPosts) < 2) return;
|
||||
?>
|
||||
|
||||
<div class="authors-last-publications">
|
||||
<?php if (count($authors) <= 1) : ?>
|
||||
<h3 class="title-small">Ses dernières publications</h3>
|
||||
<?php else : ?>
|
||||
<h3 class="title-small">Leurs dernières publications</h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($authorsLastPosts as $post) : ?>
|
||||
<?php get_template_part('template-parts/articles/card-article', null, array(
|
||||
'ID' => $post->ID,
|
||||
'showAuthors' => true,
|
||||
)); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php wp_reset_postdata(); ?>
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
$postId = $args['postId'];
|
||||
$isArticle = is_singular('articles');
|
||||
$componentTitle = $isArticle ? 'Auteur·e·s de l\'article' : 'Auteur·e·s de la revue';
|
||||
|
||||
$authors = [];
|
||||
|
||||
if ($isArticle) {
|
||||
$authors = get_field('authors', $postId);
|
||||
} else {
|
||||
$authors = getRevueAuthors($postId);
|
||||
}
|
||||
|
||||
if (empty($authors)) return;
|
||||
|
||||
?>
|
||||
<section class="authors-list">
|
||||
<h3 class="authors-list__title"><?php echo $componentTitle; ?></h3>
|
||||
|
||||
<?php foreach ($authors as $authorID) : ?>
|
||||
<?php get_template_part(
|
||||
'template-parts/authors/card-author',
|
||||
null,
|
||||
array(
|
||||
'ID' => $authorID,
|
||||
)
|
||||
); ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
$ID = $args['ID'];
|
||||
$name = get_the_title($ID);
|
||||
$link = get_the_permalink($ID);
|
||||
$profilePicture = get_field('profile_thumbnail', $ID);
|
||||
$profilePictureUrl = $profilePicture['url'] ?? '';
|
||||
$profilePictureAlt = $profilePicture['alt'] ?? '';
|
||||
$description = get_field('description', $ID);
|
||||
|
||||
$is_carhop_member = get_field('is_carhop_member', $ID);
|
||||
$carhop_member_id = get_field('carhop_member', $ID);
|
||||
|
||||
if ($is_carhop_member && isset($carhop_member_id)) {
|
||||
switch_to_blog(1);
|
||||
$description = get_field('description', $carhop_member_id);
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
// write_log($is_carhop_member);
|
||||
|
||||
$totalArticles = count_user_articles($ID, 'articles');
|
||||
?>
|
||||
|
||||
<a href="<?php echo $link; ?>" class="author-card">
|
||||
<div class="author-card__profile-picture">
|
||||
<?php if ($profilePictureUrl) : ?>
|
||||
<img src="<?php echo $profilePictureUrl; ?>" alt="<?php echo $profilePictureAlt; ?>">
|
||||
<?php else : ?>
|
||||
<div class="author-card__profile-picture-placeholder">
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="author-card__infos">
|
||||
<h3 class="author-card__name"><?php echo $name; ?></h3>
|
||||
<p class="author-card__articles-amount"><?php echo $totalArticles; ?> article<?php echo $totalArticles > 1 ? 's' : ''; ?></p>
|
||||
</div>
|
||||
|
||||
<div class="author-card__description">
|
||||
<?php echo $description; ?>
|
||||
</div>
|
||||
</a>
|
||||
Loading…
Reference in New Issue
Block a user