Passer au contenu principal

Celia Cuisine

Autour de la cuisine

Chargement des articles...
.cc-category-posts { width: 100%; } .cc-category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; } .cc-category-card { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 8px 22px rgba(0,0,0,0.08); transition: all 0.3s ease; } .cc-category-card:hover { transform: translateY(-6px); box-shadow: 0 16px 35px rgba(0,0,0,0.15); } .cc-category-card img { width: 100%; height: 170px; object-fit: cover; display: block; transition: transform 0.4s ease; } .cc-category-card:hover img { transform: scale(1.06); } .cc-category-content { padding: 16px; } .cc-category-content h3 { font-size: 18px; margin: 0 0 10px; line-height: 1.3; } .cc-category-content h3 a { color: #111; text-decoration: none; } .cc-category-card:hover h3 a, .cc-read-more:hover { color: #026bff; } .cc-category-content p { font-size: 14px; line-height: 1.5; margin-bottom: 14px; } .cc-read-more { display: inline-block; font-weight: 600; text-decoration: none; color: #000; } .cc-load-more-wrap { text-align: center; margin-top: 30px; } .cc-load-more { display: none; background: #026bff; color: #fff; border: none; border-radius: 999px; padding: 13px 32px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.3s ease; } .cc-load-more:hover { transform: translateY(-3px); background: #111; } @media (max-width: 1024px) { .cc-category-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 600px) { .cc-category-grid { grid-template-columns: 1fr; } } (function () { document.querySelectorAll('.cc-category-posts').forEach(function(section) { if (section.dataset.initialized === 'true') return; section.dataset.initialized = 'true'; const categorySlug = section.dataset.category; const grid = section.querySelector('.cc-category-grid'); const button = section.querySelector('.cc-load-more'); const postsPerLoad = 8; let currentPage = 1; let categoryId = null; let totalPages = 1; function cleanText(html, limit) { const div = document.createElement('div'); div.innerHTML = html; const text = div.textContent || div.innerText || ''; return text.length > limit ? text.substring(0, limit) + '...' : text; } function getImage(post) { if ( post._embedded && post._embedded['wp:featuredmedia'] && post._embedded['wp:featuredmedia'][0] ) { return post._embedded['wp:featuredmedia'][0].source_url; } return ''; } function createCard(post) { const image = getImage(post); const excerpt = cleanText(post.excerpt.rendered, 110); return ` `; } function updateButton() { button.style.display = currentPage < totalPages ? 'inline-block' : 'none'; } function loadPosts() { button.disabled = true; button.textContent = 'Chargement...'; fetch(`/wp-json/wp/v2/posts?categories=${categoryId}&per_page=${postsPerLoad}&page=${currentPage}&_embed`) .then(function(response) { totalPages = parseInt(response.headers.get('X-WP-TotalPages'), 10) || 1; return response.json(); }) .then(function(posts) { if (currentPage === 1) grid.innerHTML = ''; if (!posts.length && currentPage === 1) { grid.innerHTML = 'Aucun article trouvé.'; button.style.display = 'none'; return; } posts.forEach(function(post) { grid.innerHTML += createCard(post); }); button.disabled = false; button.textContent = 'Afficher plus'; updateButton(); }) .catch(function() { grid.innerHTML = 'Impossible de charger les articles.'; button.style.display = 'none'; }); } fetch(`/wp-json/wp/v2/categories?slug=${categorySlug}`) .then(function(response) { return response.json(); }) .then(function(categories) { if (!categories.length) { grid.innerHTML = 'Catégorie introuvable. Vérifie le slug.'; button.style.display = 'none'; return; } categoryId = categories[0].id; loadPosts(); }) .catch(function() { grid.innerHTML = 'Impossible de charger cette catégorie.'; button.style.display = 'none'; }); button.addEventListener('click', function() { currentPage++; loadPosts(); }); }); })();
Celia Cuisine

Hello Mézanmi 👋
Quel plaisir de te rencontrer
!

Avant de partir, inscris-toi à notre newsletter pour recevoir du contenu gourmand dans ta boîte mail.

Nous n'envoyons pas de spam !