/*
Theme Name: Blocksy Child
Theme URI: https://creativethemes.com/blocksy/
Template: blocksy
Author: CreativeThemes
Author URI: https://creativethemes.com
Description: Blocksy is a fast, modern WordPress theme with advanced WooCommerce support and full compatibility with the block editor.
Tags: accessibility-ready,blog,block-patterns,e-commerce,wide-blocks,block-styles,grid-layout,one-column,two-columns,three-columns,four-columns,right-sidebar,left-sidebar,translation-ready,custom-colors,custom-logo,custom-menu,featured-images,footer-widgets,full-width-template,theme-options,threaded-comments
Version: 2.1.28.1771017445
Updated: 2026-02-13 21:17:25

<?php
/**
 * Template Name: Home Lumens
 */
get_header();

$excluded_ids = [];

function lumens_cat_id($slug) {
  $cat = get_category_by_slug($slug);
  return $cat ? (int) $cat->term_id : 0;
}

$cat_en_lumiere  = lumens_cat_id('en-lumiere');
$cat_musique     = lumens_cat_id('musique');
$cat_evenements  = lumens_cat_id('evenements');
$cat_decryptages = lumens_cat_id('decryptages');

?>

<div class="lumens-wrap">

<div class="lumens-top">

<?php
// ========================
// 1️⃣ EN LUMIÈRE
// ========================

$featured = new WP_Query([
  'post_type' => 'post',
  'posts_per_page' => 1,
  'cat' => $cat_en_lumiere
]);

if ($featured->have_posts()):
while ($featured->have_posts()): $featured->the_post();
$excluded_ids[] = get_the_ID();
?>

<article class="lumens-featured">
  <a href="<?php the_permalink(); ?>">
    <?php the_post_thumbnail('full'); ?>
    <span class="lumens-pill">En lumière</span>
    <h1><?php the_title(); ?></h1>
  </a>
</article>

<?php
endwhile;
wp_reset_postdata();
endif;
?>

<div class="lumens-news">

<?php
// ========================
// 2️⃣ DERNIÈRES ACTUALITÉS
// ========================

$news = new WP_Query([
  'post_type' => 'post',
  'posts_per_page' => 4,
  'post__not_in' => $excluded_ids
]);

if ($news->have_posts()):
while ($news->have_posts()): $news->the_post();
$excluded_ids[] = get_the_ID();
?>

<article class="lumens-news-card">
  <a href="<?php the_permalink(); ?>">
    <?php the_post_thumbnail('large'); ?>
    <span class="lumens-pill small">Dernières actualités</span>
    <h3><?php the_title(); ?></h3>
  </a>
</article>

<?php
endwhile;
wp_reset_postdata();
endif;
?>

</div>
</div>

<?php
// ========================
// 3️⃣ SECTIONS CATÉGORIES
// ========================

function lumens_section($title, $cat_id, &$excluded_ids) {

$q = new WP_Query([
  'post_type' => 'post',
  'posts_per_page' => 3,
  'cat' => $cat_id,
  'post__not_in' => $excluded_ids
]);

if ($q->have_posts()):
?>

<section class="lumens-section">
  <div class="lumens-section-head">
    <h2><?php echo $title; ?></h2>
    <a href="<?php echo get_category_link($cat_id); ?>">Voir tout</a>
  </div>

  <div class="lumens-grid">

<?php
while ($q->have_posts()): $q->the_post();
$excluded_ids[] = get_the_ID();
?>

<article class="lumens-card">
  <a href="<?php the_permalink(); ?>">
    <?php the_post_thumbnail('large'); ?>
    <h3><?php the_title(); ?></h3>
  </a>
</article>

<?php endwhile; ?>

  </div>
</section>

<?php
wp_reset_postdata();
endif;
}

lumens_section('Musique', $cat_musique, $excluded_ids);
lumens_section('Événements', $cat_evenements, $excluded_ids);
lumens_section('Décryptages', $cat_decryptages, $excluded_ids);

?>

</div>

<?php get_footer(); ?>


*/

