Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coupe WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Comment afficher les publications récentes dans WordPress

Note éditoriale : Nous percevons une commission sur les liens des partenaires sur WPBeginner. Les commissions n'affectent pas les opinions ou les évaluations de nos rédacteurs. En savoir plus sur Processus éditorial.

Voulez-vous afficher vos publications récentes dans WordPress ? L’affichage des publications récentes aide les utilisateurs/utilisatrices à découvrir facilement votre nouveau contenu et à passer plus de temps sur votre site.

Vous pouvez ajouter une liste de vos dernières publications dans votre colonne latérale, après la fin du contenu de votre publication, à l’intérieur du contenu de votre publication avec un code court, dans la zone de widget de votre pied de page, ou n’importe où ailleurs.

Dans cet article, nous allons vous afficher comment afficher les publications récentes dans WordPress en utilisant différentes méthodes.

How to display recent posts in WordPress

Pourquoi ajouter des publications récentes dans WordPress ?

Si vous gérez un blog ou un site WordPress depuis longtemps, il se peut que vous ayez des articles plus anciens qui reçoivent un trafic régulier des moteurs de recherche et d’autres sources.

Un grand nombre d’internautes consultent les informations qu’ils recherchent et s’en vont. Plus de 75 % de ces internautes ne reverront jamais votre site.

Pour que les utilisateurs/utilisatrices reviennent sur votre site, vous devez faire en sorte qu’ils y passent plus de temps.

Une façon de le faire est d’afficher d’autres publications récentes qu’ils devraient voir. Cela aide les utilisateurs/utilisatrices à découvrir plus de contenu sur votre site, ce qui les amène à passer plus de temps sur votre site.

Au fur et à mesure que les utilisateurs/utilisatrices voient plus de pages, cela vous donne le temps de les convaincre de s’inscrire à votre bulletin d’information par e-mail ou de faire un achat.

Ceci étant dit, voyons comment afficher facilement les publications récentes dans WordPress en utilisant plusieurs méthodes. Vous pouvez cliquer sur les liens rapides ci-dessous pour passer directement aux différentes méthodes :

Tutoriel vidéo

Subscribe to WPBeginner

Si vous préférez des instructions écrites, continuez à lire.

Méthode 1 : utiliser le bloc Gutenberg des dernières publications de WordPress.

L’éditeur WordPress block (Gutenberg) dispose d’un bloc intégré pour afficher vos dernières publications. Vous pouvez facilement l’ajouter à n’importe quelle publication ou page de votre site.

Pour utiliser ce bloc, il suffit de modifier la publication dans laquelle vous souhaitez afficher les derniers messages. Sur l’écran de modification de la publication, vous devez ajouter le bloc « Derniers messages » à la zone de contenu.

Add latest posts block

Ce bloc peut être configuré de différentes manières. Par défaut, il affiche simplement les titres des publications, mais vous pouvez facilement le personnaliser.

Par exemple, vous pouvez permuter le contenu de la publication dans le volet de droite. Vous pouvez ainsi choisir d’ajouter le contenu de la publication ou l’extrait à côté du titre.

Vous pouvez également personnaliser la longueur de l’extrait, qui est par défaut de 55 mots, mais vous pouvez choisir n’importe quelle valeur entre 10 et 100 mots.

Show post content in recent posts

Si vous le souhaitez, vous pouvez également afficher la date de publication et l’auteur/autrice de la publication.

Il suffit d’activer les options « Afficher la date de publication » et « Afficher le nom de l’auteur » dans les Réglages des méta-publications.

Display post date and author

Vous pouvez également choisir exactement comment vos publications seront affichées. Vous pouvez les commander différemment de l’affichage par défaut « du plus récent au plus ancien », et vous pouvez afficher uniquement les dernières publications d’une catégorie spécifique.

Dans le panneau des Réglages, vous pouvez également choisir le nombre de publications à afficher. Par défaut, le bloc affiche 5 publications, mais vous pouvez afficher entre 1 et 100 publications.

Sort and filter recent posts

Vous avez également l’option d’afficher vos publications récentes dans une grille de colonnes plutôt que dans une liste.

Il suffit de sélectionner l’option « Vue en grille » dans la barre d’outils.

View latest posts in grid view

Vous pouvez personnaliser la grille à l’aide des Réglages situés à droite de l’écran.

Par exemple, vous pouvez afficher des images mises en avant pour vos publications, redimmensionner les images et les aligner en conséquence.

Show featured images in latest posts

Une fois que vous avez terminé, vous pouvez prévisualiser la publication pour la voir sur votre site.

Voici à quoi ressemble le bloc fini en direct sur notre site de test.

Latest posts preview

Méthode 2 : Utiliser le widget des publications récentes de WordPress

Que faire si vous souhaitez afficher une liste de vos dernières publications dans votre colonne latérale plutôt que sur une page ? WordPress est livré avec un widget intégré par défaut pour afficher les dernières publications dans la colonne latérale de votre site ou dans n’importe quelle zone prête à accueillir un widget.

Dans votre tableau de bord WordPress, allez dans Apparence  » Widgets et ajoutez le bloc de widgets  » Dernières publications  » à votre colonne latérale.

Add latest post widget block

Vous pouvez ensuite personnaliser l’apparence de vos publications récentes dans la colonne latérale.

Par exemple, WordPress vous permet d’afficher le contenu des articles, d’indiquer l’auteur/autrice et la date de l’article, d’activer les images mises en avant et de trier vos dernières publications.

Customize recent posts widget block

Une fois que vous avez terminé, cliquez sur le bouton « Mettre à jour » pour stocker les réglages de votre widget.

Voici le widget en direct sur le blog, avec le titre ‘New Posts’ et les dates activées :

Latest posts in sidebar menu

Méthode 3 : Utiliser le widget des publications récentes avec miniatures (Recent Posts Widget With Thumbnails Plugin)

Le widget intégré que nous avons mentionné plus haut est assez limité.

Que faire si vous souhaitez afficher des miniatures et des extraits avec vos publications récentes ? Que faire si vous souhaitez afficher uniquement les publications d’une catégorie spécifique dans votre colonne latérale ?

C’est là que le plugin Recent Posts Widget With Thumbnails (widget des publications récentes avec miniatures) est utile. Il fait bien plus que des miniatures, et il est gratuit.

Tout d’abord, vous devez installer et activer le plugin WordPress Recent Posts Widget With Thumbnails.

Ensuite, rendez-vous sur la page Apparence  » Widgets, puis ajoutez le bloc de widgets ‘Recent Posts With Thumbnails’.

Add recent posts with thumbnails widget block

Le widget Recent Posts With Thumbnails est livré avec de nombreuses options. Il vous donne un contrôle total sur la façon dont vous souhaitez afficher les publications récentes sur votre site WordPress.

Vous pouvez également afficher des extraits, des publications de catégories spécifiques, ignorer les publications épinglées, choisir le nombre de publications à afficher, afficher les auteurs/autrices, etc.

Customize recent posts with thumbnails

Une fois que vous avez terminé, n’oubliez pas de cliquer sur le bouton « Mettre à jour » pour stocker vos Réglages.

Vous pouvez maintenant visiter votre site pour voir vos publications récentes avec des miniatures.

Recent posts widget with thumbnails preview

Méthode 4 : Afficher les publications récentes à l’aide d’un code court

L’utilisation du bloc  » Derniers articles  » est certainement le moyen le plus simple d’afficher les publications récentes dans les articles et les pages de WordPress. Cependant, si vous choisissez de désactiver Gutenberg et de conserver l’éditeur Classic, alors vous pouvez utiliser des codes courts à la place.

Tout d’abord, installez et activez l’extension Relevant. Si vous avez besoin d’aide, veuillez consulter notre guide sur l ‘installation d’une extension WordPress.

C’est l’une des extensions de publication les plus populaires pour WordPress. Vous disposez de nombreuses options pour personnaliser l’apparence de vos derniers articles, comme la modification du titre, le nombre de publications, la sélection de l’affichage d’une mis en avant, d’un extrait, de la date de publication, et plus encore.

Change relevant settings

Ensuite, il vous suffit de modifier un article ou une page où vous souhaitez afficher vos publications récentes, puis d’utiliser le code court [bws_latest_posts].

Voici à quoi ressemblait notre liste de publications récentes, en suivant ces instructions :

Display recent posts shortcode

Méthode 5 : Afficher manuellement les publications récentes dans WordPress

Les utilisateurs/utilisatrices plus avancés de WordPress peuvent vouloir ajouter les publications récentes directement dans les fichiers de leur thème WordPress. Bien sûr, vous devriez utiliser un thème enfant pour cela afin que lorsque vous mettez à jour votre thème, vous ne perdiez pas vos modifications.

C’est toujours une bonne idée de créer une sauvegarde avant de modifier les fichiers de votre thème. En cas de problème, vous pouvez consulter notre liste des erreurs WordPress les plus courantes et la manière de les corriger.

La façon la plus simple d’afficher manuellement les publications récentes est d’utiliser la classe WP_Query intégrée. Ajoutez simplement ce code à l’endroit où vous souhaitez afficher les publications récentes :

<ul>
 
<?php
// Define our WP Query Parameters
$the_query = new WP_Query( 'posts_per_page=5' ); ?>
 
<?php
// Start our WP Query
while ($the_query -> have_posts()) : $the_query -> the_post();
// Display the Post Title with Hyperlink
?>
 
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
 
<li><?php
// Display the Post Excerpt
the_excerpt(__('(more…)')); ?></li>
 
<?php
// Repeat the process and reset once it hits the limit
endwhile;
wp_reset_postdata();
?>
</ul>

Ce code affiche les cinq publications les plus récentes avec leurs titres et extraits. La classe WP_Query possède des tonnes de paramètres qui vous permettent de la personnaliser à votre guise. En savoir plus, veuillez vous référer à la documentation développeur/développeuse de WordPress.

Guides d’experts sur la recommandation de publications dans WordPress

Maintenant que vous savez comment afficher les publications récentes dans WordPress, vous pouvez consulter d’autres articles similaires liés à la promotion du contenu auprès de vos lecteurs.

Nous espérons que cet article vous a aidé à apprendre comment afficher les publications récentes sur WordPress. Vous pourriez également être intéressé par notre guide sur la façon de créer une page séparée pour les articles de blog dans WordPress et notre choix d’experts des meilleurs plugins de constructeur de page WordPress par glisser-déposer.

Si vous avez aimé cet article, veuillez alors vous abonner à notre chaîne YouTube pour obtenir des tutoriels vidéo sur WordPress. Vous pouvez également nous trouver sur Twitter et Facebook.

Divulgation : Notre contenu est soutenu par les lecteurs. Cela signifie que si vous cliquez sur certains de nos liens, nous pouvons gagner une commission. Consultez comment WPBeginner est financé, pourquoi cela compte et comment vous pouvez nous soutenir. Voici notre processus éditorial.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

L'ultime WordPress Toolkit

Accédez GRATUITEMENT à notre boîte à outils - une collection de produits et de ressources liés à WordPress que tous les professionnels devraient avoir !

Reader Interactions

141 commentairesLaisser une réponse

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Louise says

    Hi,
    Thank you for this post. Really helped a lot.
    But then I have a problem. When I click on one of the recent posts – it directed me to the static page and not the post itself. Kindly help me resolved this issue. Thank you.

  3. Ellen Allard (Gluten Free Diva) says

    So glad to have found you!

    I’m confused – I can’t seem to get my most recent blog post to appear on my blog page. Can you advise please? Thank you so much!

    best, Ellen Allard, Gluten Free Diva

  4. Tim Zeman says

    So I was able to get the 5 latest post to show in the right sidebar but when I click on a post to read it I get the following error on Home Page Oops something went wrong

    How do I get the selected post to display?

  5. Val Archer says

    Hi – thanks million for this manual method, very grateful. Please can you tell me how to add a thumbnail image to it? I’m referring to the method starting:

    // Define our WP Query Parameters

    • Andrew Wilkerson says

      Hi Val, Hope your doing well, I was just scrolling through this article and saw your name and thought straight away I know that name! It’s a small world.
      I made one of your sprouters in the late 90’s I think it would have been.
      Funny thing is I was just thinking about building another one a few days ago!

      Crazy how things happen sometimes!
      Weird that I then just stumbled across your comment on here today in 2018 while I’m working on my website for something totally unrelated.

      I remember I really enjoyed reading about your life and the move to Sth Africa, your cures for tooth aces etc. I’ll have to have another look into it all again soon when I have time, anyway just thought I’d say Hi.

  6. Joe says

    Hi,

    On my recent posts on the sidebar, when I click a specific post it brings me to the latest post and then displays everything. How do I get it so that when I click a specific post it only shows that post?

    Thanks!

  7. Sally says

    Is there a code I can add to activate pagination using the Recent Posts Extended widget?

    Currently I have my home page widgetized so I’m using the widget.

    Thanks!

  8. Jason says

    The version I downloaded does not include the ability to display thumbnails…cant see the option anywhere. I am using version 0.9.9

    Any clues?

  9. andrea says

    Hi, my issue is to display the latest post full content in a static home page… and i was thinking that the last snippet was what i needed… but unfortunately it does not works properly. In effects it shows title but not the content. could u help me please

  10. Tushar says

    Hi I am new on wordpress, I want to show Client Testimonial using post….How should I do it..? any suggestions please ?

  11. WPBeginner Staff says

    Here is an easier way. Install Display Posts Shortcode plugin. Create a blank page and add the shortcode as described in plugins documentation. Publish the page. Go to Settings > Reading and select the page you just created as your static page. Redit the static page and add the slider just before the display posts shortcode. Hope this helps you.

  12. Emily says

    Hi, I am wanting to add a slider to the top of my homepage, but it will only allow me to do so if I use a static page. Right now when you go directly to my website, it is my latest posts in full length. If I change my homepage to a static page so that I can include the slider, will this work to add the recent posts below, just as it appears now? Where would I be posting this code? Into the static homepage?

    Note– I recently tried messing with my php and broke my code and had some major issues.. so I’m pretty nervous messing with php.

  13. Subrata says

    hi!…can anyone tell me how to display top rated blog posts (only 5) in increasing order (numeric order) by using PHP codes?

  14. Oliver says

    Hi there. I am a designer so I’ve never been good at PHP. At least I can read and change it for my conditions most of the time. This time I’d like to call for the nine latest posts excluding the very last one inside my slideshow container.

    For now I just set the first post on display none. This works fine; however the slideshow still counts to ten. That’s why you find the last page empty.
    Is there any way to exclude the very last post when calling for recent posts? Thank you so much in advance!

  15. KalanaDe says

    Hi, I want to display blog posts only from a category called ‘Blog’ only. (I want to exclude all other posts from other categories.) What should I add to this code.?

  16. Bucur says

    showposts is deprecated. However, posts_per_page is perfect for use with query_posts(), or even more particularly, WP_Query::query().

    numberposts may be the equivalent argument for get_posts().

  17. Art says

    Good article.

    One piece of info that would increase it’s usefulness though, is how to (or a plugin that can) include an offset.

    For example, I want my two most recent posts to be full text — got that.
    But what if I want the next 10 to be excerpts, and maybe the next 10 older to be headlines only — the list?

    So — how can you include an offset?

    Cheers,
    Art

  18. Ryan says

    Hi there,

    I want my latest 4 posts to display inline across the screen, how would I do this?

    Currently they only display down the page.

    Thanks

    Ryan

    • Mike says

      Sounds like you need to create a container with the height/width you want the posts to appear as. Then allow them to wrap over.. make sure that the last piece of your « Post » code doesn’t have a line break.

  19. Wilko says

    Great post! Thanks!

    Just one question. Is it possible to hide the latest post out of 5? I mean on my website I display the latest post already with full content, so I would like to hide the first.

  20. Jeremy says

    Finally a quick and to the point tutorial on this topic. Other posts on calling in the recent blog posts were not as quick and too the point. Thanks :D

  21. Ellery Davies says

    Hi Syed,

    I use the WordPress Twenty-Eleven theme and have always displayed recent posts using the widget in Jetpack. But I want this list to show in the individual posts as well. Is there a way to do this? If it involves pasting code, into which file do I paste?

      • Ellery Davies says

        The home page of AWildDuck -d0t- com, shows recent posts along the right side, along with subscribe and a tag cloud. But this appears only on the home page. If I send you a link to any individual post (or if you click on the title of any post), the right frame disappears. My visitors can no longer see a list of recent posts. I am very frustrated by this, and I want to know how to get that list of recent posts to appear on all pages. (Not just the home page).

        • Ellery Davies says

          Hi Syed,
          Indeed, this is my current setting. It has always been my setting. Twenty Eleven with « Content on left ».

        • Ellery Davies says

          I don’t understand… Do you see Recent Posts on the right, even when you are looking at an individual post? If you do, are you using JetPack/Recent Posts?

          If the answer to both questions is « Yes », would you please send me your phone number. You already have my email address. -Or call me: Area code « Five-Oh-EIght », 485 ..695O.

          Thanks, –Ellery

      • darknote says

        thank you, yes, but I ask not only for me but thinking of other visitors, it can be more useful in your article, give an example of recent articles with thumbnails.

      • Kylie says

        Thanks so much for this tutorial! I used the code to display recent posts with a summary on my website’s homepage.

        When adding the_post_thumbnail(); code could you please tell me what file and where in the file to add it? I tried looking it up and experimented by adding it to several files on my own and was not able to get the thumbnails to show up.

        Any insight would be greatly appreciated.

        Thank you,

        Kylie

        • WPBeginner Support says

          In your Post Edit area, post thumbnails are called featured image. If you can not see a featured image meta box, then click on Screen Options button on the top right corner of your post edit screen and check Featured image.

  22. vajrasar says

    Nice Post.
    How can I achieve – Recent Posts in Menu. Like I have my category « Crime » on top-menu. Now whenever a user hover it, I want to show 5 recent posts from category « Crime » with their thumbnails?

  23. broghanreilly says

    I have tried to use this code and it doesn’t seem to work? I am a beginner and am using a standard theme and not hosting. Therefore I can’t upload anything I can only use HTML.

  24. Panoz says

    My WP homepage has a footer displaying the titles of my 4 latest posts (Recent Posts). This makes no sense, as these posts are already displayed above.

    My question is how can my footer display the range between 5th and 8th post ??

    The code its currently using is

    <?php wp_get_archives('type=postbypost&limit=5');

    Many thanx in advance for your help

      • Panoz says

        Thank you very much for your kind reply. Can you please let me know how I can do that? I know very few stuff and i definately need to have this done by the day after tomorrow that I’m launching my site.
        Thanks

  25. Phelan says

    I’ve been looking for this code for a few days now. I can’t believe it’s not more readily available in the Template Tags pages or any other blogs.

    I changed the code to include tags and tags instead of the tags like the following:

    <a href=" »>

    Thanks for posting!

  26. Katie says

    One problem with the above code is when you call that function in your sidebar which is called before the start of the loop in single.php. Your single.php file will list down all the articles of your blog post irrespective of the one which is called.

    In such cases, you can also use

    Otherwise, calling query_posts(‘showposts=10’); function is fine.

    Both of them will list down latest 10 posts in ul, li format. This is bit easier.

  27. Mike says

    Hi, is it possible to show the date before the linked post title when using:
    <?php get_archives('postbypost', '10', 'custom', '’,  »); ?>

    Thanks

  28. ali says

    Hi Guys

    I seem to be having some issues with this code. It works great on my index.php page but when I try adding it to either the page.php or single.php it prevents other content showing. For example when I click the ‘about us’ page it will display the latest article!

    Hope this makes sense and any help anyone can offer would be greatly appreciated.

    Thanks

  29. ravi says

    i want to display posts in order of post date.. recent one first with pagination i am able to do the pagination but the posts are displaying on each page in random order somebody please help………….:(

  30. Mark says

    I want to know how to display rcenet posts with thimthumb thumbnial.

    Unfortunately Google is being Google as usual and not giving me the results I want.

    Thanks.

    • Editorial Staff says

      You can simply add timthumb codes anywhere in these codes, and it should work. The query will be run the exact same way. If you are looking for a step by step guide, we haven’t written one. Although we might write one in the future.

      Administrateur

  31. DaveK says

    I am so glad I found this, I have been trying to do this for days and I couldnt find exactly how to do this on the wordpress codex !!! the only sollution they seemed to offer screwed up the custom homepage I built, but this works perfect.

    Thanks very much.

  32. Justin says

    Good info!

    I’m trying to display the latest 5 posts using the last method you described, but I can’t figure out how to get page numbers. For example, the faux blog page displays the last five posts, but there is no way to go back in time from there.

    I have not been able to find a solution for this. Any suggestions?

    Thanks!

Laisser une réponse

Merci d'avoir choisi de laisser un commentaire. Veuillez garder à l'esprit que tous les commentaires sont modérés selon notre politique de commentaires, et votre adresse e-mail ne sera PAS publiée. Veuillez NE PAS utiliser de mots-clés dans le champ du nom. Ayons une conversation personnelle et significative.