MAKE YOUR BUSINESS
Get Started
Share your challenge with our team and we l work with you to deliver a revolutionary digital product.Share your challenge with our team and we l work with you to deliver a revolutionary digital product.Share your challenge with our team and we l work with you to deliver a revolutionary digital product.Share your challenge with our team and we l work with you to deliver a revolutionary digital product.
function afficher_articles_personnalises() {
// Requête pour récupérer les derniers articles
$args = array(
'post_type' => 'post',
'posts_per_page' => 4, // Nombre d'articles à afficher
);
$query = new WP_Query($args);
if ($query->have_posts()) {
echo '<div class="articles-container" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;">';
while ($query->have_posts()) {
$query->the_post();
echo '<div class="article-card" style="border: 1px solid #ddd; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">';
if (has_post_thumbnail()) {
echo '<div class="article-image" style="height: 200px; overflow: hidden;">';
the_post_thumbnail('medium', ['style' => 'width: 100%; height: 100%; object-fit: cover;']);
echo '</div>';
}
echo '<div class="article-content" style="padding: 15px;">';
echo '<h2 style="font-size: 20px; margin: 0;"><a href="' . get_permalink() . '" style="text-decoration: none; color: #333;">' . get_the_title() . '</a></h2>';
echo '<p style="margin: 10px 0; color: #555;">' . get_the_excerpt() . '</p>';
echo '<a href="' . get_permalink() . '" style="display: inline-block; padding: 10px 15px; background-color: #0073aa; color: #fff; text-decoration: none; border-radius: 5px;">Lire plus</a>';
echo '</div>';
echo '</div>';
}
echo '</div>';
wp_reset_postdata();
} else {
echo '<p>Aucun article trouvé.</p>';
}
}
// Ajouter un shortcode pour l'affichage des articles
add_shortcode('afficher_articles', 'afficher_articles_personnalises');