| Linux webm001.cluster123.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 Path : /home/lapjouc/www/wp-content/themes/laap/ |
| Current File : /home/lapjouc/www/wp-content/themes/laap/sidebar-journal-edition.php |
<?php
if (!is_single()) {
return;
}
$categories = get_the_category();
if (empty($categories)) {
return;
}
// Find the journal edition category (e.g., "lap-1", "lap-2")
$journal_category = null;
foreach ($categories as $category) {
if (strpos($category->slug, 'lap-') === 0) {
$journal_category = $category;
break;
}
}
if (!$journal_category) {
return;
}
$journal_category_id = $journal_category->term_id;
// Query for posts in the same journal edition
$args = array(
'cat' => $journal_category_id,
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC',
'post__not_in' => array(get_the_ID()), // Exclude current post
);
$journal_query = new WP_Query($args);
if ($journal_query->have_posts()) :
?>
<aside id="secondary" class="widget-area">
<?php dynamic_sidebar('journal-edition-sidebar'); ?>
<div class="journal-edition-posts">
<?php
// Separate posts into 'A la Une', 'Edito', and other posts
$a_la_une_post = null;
$edito_post = null;
$other_posts = array();
while ($journal_query->have_posts()) : $journal_query->the_post();
if (has_category('a-la-une')) {
$a_la_une_post = $post;
} elseif (has_category('edito')) {
$edito_post = $post;
} else {
$other_posts[] = $post;
}
endwhile;
// Display 'A la Une' post
if ($a_la_une_post) :
?>
<div class="a-la-une-post">
<h3><?php _e('A la Une', 'your-theme'); ?></h3>
<a href="<?php echo get_permalink($a_la_une_post); ?>"><?php echo get_the_title($a_la_une_post); ?></a>
</div>
<?php
endif;
// Display 'Edito' post
if ($edito_post) :
?>
<div class="edito-post">
<h3><?php _e('Edito', 'your-theme'); ?></h3>
<a href="<?php echo get_permalink($edito_post); ?>"><?php echo get_the_title($edito_post); ?></a>
</div>
<?php
endif;
// Display other posts
if (!empty($other_posts)) :
?>
<ul class="other-posts">
<?php foreach ($other_posts as $post) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; wp_reset_postdata(); ?>
</ul>
<?php
endif;
?>
</div>
</aside>
<?php
endif;
wp_reset_postdata();
?>