Accès au catalogue :
[raw]
<!-- ============================================================
BANNIÈRE DÉFILANTE WORDPRESS — Articles par catégorie
À coller dans un bloc "HTML personnalisé" de WordPress
============================================================
✅ CONFIGURATION :
1. Remplacez VOTRE_CATEGORY_ID par l'ID de votre catégorie
(trouvable dans Articles >--> Catégories > survolez la catégorie,
l'ID apparaît dans l'URL ex: tag_ID=5)
2. Remplacez VOTRE_SITE.com par votre domaine WordPress
3. Ajustez NB_ARTICLES si besoin (max 100)
4. Ajustez VITESSE_MS (millisecondes entre chaque slide)
============================================================ -->
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Lato:wght@300;400;700&display=swap');
.wp-banner-slider {
position: relative;
width: 100%;
max-width: 100%;
overflow: hidden;
border-radius: 10px;
background: #111;
font-family: 'Lato', sans-serif;
box-shadow: 0 8px 32px rgba(0,0,0,0.25);
aspect-ratio: 32/5;
min-height: 90px;
}
.wp-banner-track {
display: flex;
width: 100%;
height: 100%;
transition: transform 0.7s cubic-bezier(0.77, 0, 0.175, 1);
}
.wp-banner-slide {
min-width: 100%;
height: 100%;
position: relative;
overflow: hidden;
cursor: pointer;
text-decoration: none;
display: block;
flex-shrink: 0;
}
.wp-banner-slide img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
transition: transform 6s ease;
}
.wp-banner-slide:hover img {
transform: scale(1.04);
}
/* Dégradé sombre en bas */
.wp-banner-slide::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(
to bottom,
transparent 30%,
rgba(0,0,0,0.3) 60%,
rgba(0,0,0,0.82) 100%
);
}
.wp-banner-caption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 18px 24px 20px;
z-index: 2;
}
.wp-banner-label {
display: inline-block;
background: #e63946;
color: #fff;
font-size: 10px;
font-weight: 700;
letter-spacing: 2px;
text-transform: uppercase;
padding: 3px 10px;
border-radius: 3px;
margin-bottom: 8px;
}
.wp-banner-title {
font-family: 'Bebas Neue', sans-serif;
color: #ffffff;
font-size: clamp(18px, 3.5vw, 32px);
line-height: 1.15;
margin: 0;
text-shadow: 0 2px 8px rgba(0,0,0,0.5);
letter-spacing: 0.5px;
}
/* Boutons nav */
.wp-banner-prev,
.wp-banner-next {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 10;
background: rgba(255,255,255,0.15);
border: 1px solid rgba(255,255,255,0.3);
color: #fff;
width: 36px;
height: 36px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
backdrop-filter: blur(4px);
transition: background 0.2s;
}
.wp-banner-prev:hover,
.wp-banner-next:hover {
background: rgba(255,255,255,0.35);
}
.wp-banner-prev { left: 12px; }
.wp-banner-next { right: 12px; }
/* Indicateurs (dots) */
.wp-banner-dots {
position: absolute;
bottom: 10px;
right: 16px;
display: flex;
gap: 6px;
z-index: 10;
}
.wp-banner-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: rgba(255,255,255,0.4);
cursor: pointer;
transition: background 0.3s, transform 0.3s;
border: none;
padding: 0;
}
.wp-banner-dot.active {
background: #fff;
transform: scale(1.3);
}
/* Barre de progression */
.wp-banner-progress {
position: absolute;
bottom: 0;
left: 0;
height: 3px;
background: #e63946;
width: 0%;
z-index: 10;
transition: none;
}
/* Placeholder chargement */
.wp-banner-loading {
display: flex;
align-items: center;
justify-content: center;
color: #666;
font-size: 14px;
height: 100%;
background: #1a1a1a;
}
.wp-banner-no-image {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #1a1a2e, #16213e);
display: flex;
align-items: center;
justify-content: center;
font-size: 48px;
}
<div class="wp-banner-slider" id="wpBannerSlider">
<div class="wp-banner-track" id="wpBannerTrack">
<div class="wp-banner-loading">⏳ Chargement des articles…</div>
</div>
<button class="wp-banner-prev" id="wpBannerPrev" style="display:none">‹</button>
<button class="wp-banner-next" id="wpBannerNext" style="display:none">›</button>
<div class="wp-banner-dots" id="wpBannerDots"></div>
<div class="wp-banner-progress" id="wpBannerProgress"></div>
</div>
(function() {
/* ══════════════════════════════════════════
⚙️ CONFIGURATION — À MODIFIER
══════════════════════════════════════════ */
var CONFIG = {
siteUrl : '', // Laisser vide = site actuel. Sinon : 'https://monsite.com'
categoryId : 79, // ← ID de la catégorie WordPress
nbArticles : 8, // Nombre d'articles à afficher (max 100)
vitesseMs : 5000, // Délai entre chaque slide en ms (4000 = 4 secondes)
labelTexte : 'À la une', // Texte du badge rouge (ou '' pour masquer)
lienArticle: true // true = clic ouvre l'article
};
/* ════════════════════════════════════════ */
var track = document.getElementById('wpBannerTrack');
var dotsEl = document.getElementById('wpBannerDots');
var prevBtn = document.getElementById('wpBannerPrev');
var nextBtn = document.getElementById('wpBannerNext');
var progress = document.getElementById('wpBannerProgress');
var slides = [];
var current = 0;
var timer = null;
// Détermination de l'URL de base
var base = CONFIG.siteUrl || (window.location.protocol + '//' + window.location.host);
var apiUrl = base + '/wp-json/wp/v2/posts'
+ '?categories=' + CONFIG.categoryId
+ '&per_page=' + CONFIG.nbArticles
+ '&_embed=1'
+ '&_fields=id,title,link,_embedded,_links';
// ── Fetch articles
fetch(apiUrl)
.then(function(r) {
if (!r.ok) throw new Error('Erreur API: ' + r.status);
return r.json();
})
.then(function(posts) {
if (!posts || posts.length === 0) {
track.innerHTML = '<div class="wp-banner-loading">Aucun article trouvé dans cette catégorie.</div>';
return;
}
buildSlider(posts);
})
.catch(function(err) {
track.innerHTML = '<div class="wp-banner-loading">⚠️ ' + err.message + '</div>';
console.error('WP Banner:', err);
});
// ── Construction du slider
function buildSlider(posts) {
track.innerHTML = '';
dotsEl.innerHTML = '';
slides = [];
posts.forEach(function(post, i) {
// Image mise en avant
var imgUrl = '';
try {
imgUrl = post._embedded['wp:featuredmedia'][0].source_url;
} catch(e) { imgUrl = ''; }
var title = post.title.rendered.replace(/]+>/g, '');
var link = CONFIG.lienArticle ? post.link : '#';
// Slide
var slide = document.createElement('a');
slide.className = 'wp-banner-slide';
slide.href = link;
if (CONFIG.lienArticle) slide.setAttribute('target', '_self');
if (imgUrl) {
var img = document.createElement('img');
img.src = imgUrl;
img.alt = title;
img.loading = i === 0 ? 'eager' : 'lazy';
slide.appendChild(img);
} else {
var placeholder = document.createElement('div');
placeholder.className = 'wp-banner-no-image';
placeholder.textContent = '📰';
slide.appendChild(placeholder);
}
var caption = document.createElement('div');
caption.className = 'wp-banner-caption';
if (CONFIG.labelTexte) {
var label = document.createElement('div');
label.className = 'wp-banner-label';
label.textContent = CONFIG.labelTexte;
caption.appendChild(label);
}
var titleEl = document.createElement('p');
titleEl.className = 'wp-banner-title';
titleEl.textContent = title;
caption.appendChild(titleEl);
slide.appendChild(caption);
track.appendChild(slide);
slides.push(slide);
// Dot
var dot = document.createElement('button');
dot.className = 'wp-banner-dot' + (i === 0 ? ' active' : '');
dot.setAttribute('aria-label', 'Slide ' + (i+1));
dot.addEventListener('click', function() { goTo(i); resetTimer(); });
dotsEl.appendChild(dot);
});
prevBtn.style.display = 'flex';
nextBtn.style.display = 'flex';
prevBtn.addEventListener('click', function() { goTo(current - 1); resetTimer(); });
nextBtn.addEventListener('click', function() { goTo(current + 1); resetTimer(); });
goTo(0);
startTimer();
// Pause au hover
document.getElementById('wpBannerSlider').addEventListener('mouseenter', function() {
clearInterval(timer);
stopProgress();
});
document.getElementById('wpBannerSlider').addEventListener('mouseleave', function() {
startTimer();
});
}
function goTo(index) {
var count = slides.length;
current = (index + count) % count;
track.style.transform = 'translateX(-' + (current * 100) + '%)';
// Mise à jour des dots
var dots = dotsEl.querySelectorAll('.wp-banner-dot');
dots.forEach(function(d, i) {
d.classList.toggle('active', i === current);
});
}
function startTimer() {
animateProgress();
timer = setInterval(function() {
goTo(current + 1);
animateProgress();
}, CONFIG.vitesseMs);
}
function resetTimer() {
clearInterval(timer);
stopProgress();
startTimer();
}
function animateProgress() {
stopProgress();
progress.style.transition = 'none';
progress.style.width = '0%';
requestAnimationFrame(function() {
requestAnimationFrame(function() {
progress.style.transition = 'width ' + CONFIG.vitesseMs + 'ms linear';
progress.style.width = '100%';
});
});
}
function stopProgress() {
progress.style.transition = 'none';
progress.style.width = '0%';
}
})();
[/raw]
Votre article :
Dites adieu aux zones mortes
dans votre maison
Votre Wi-Fi s’essouffle après quelques mètres ? La solution existe, et elle est à prix imbattable.
Grande maison, palace, villa… le signal Wi-Fi classique ne suffit pas. Couloirs, étages, jardin : vous perdez la connexion là où vous en avez le plus besoin.
La solution
Le système Netgear Orbi RBR50v2 crée un réseau maillé qui couvre chaque recoin de votre maison. Fluide, puissant, sans coupure. Comme si votre box était partout à la fois.
Couverture totale
Wi-Fi AC3000
Réseau sécurisé
Prix exceptionnel pour les 3 routeurs
CHF 90.–
soit CHF 30.– par appareil — valeur marchande bien supérieure
Découvrir le produit avant d’acheter →Convaincu ? Contactez-moi
Dites adieu aux zones mortes
dans votre maison
Votre Wi-Fi s’essouffle après quelques mètres ? La solution existe, et elle est à prix imbattable.
Grande maison, palace, villa… le signal Wi-Fi classique ne suffit pas. Couloirs, étages, jardin : vous perdez la connexion là où vous en avez le plus besoin.
La solution
Le système Netgear Orbi RBR50v2 crée un réseau maillé qui couvre chaque recoin de votre maison. Fluide, puissant, sans coupure. Comme si votre box était partout à la fois.
Couverture totale
Wi-Fi AC3000
Réseau sécurisé
Prix exceptionnel pour les 3 routeurs
CHF 90.–
soit CHF 30.– par appareil — valeur marchande bien supérieure
Découvrir le produit avant d’acheter →Convaincu ? Contactez-moi
