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

Come visualizzare i post recenti in WordPress

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

Volete mostrare i vostri post recenti in WordPress? La visualizzazione dei post recenti aiuta gli utenti a scoprire facilmente i vostri nuovi contenuti e a trascorrere più tempo sul vostro sito.

È possibile aggiungere un elenco degli ultimi post nella barra laterale, alla fine del contenuto del post, all’interno del contenuto del post con uno shortcode, nell’area widget del piè di pagina o in qualsiasi altro punto.

In questo articolo vi mostreremo come visualizzare i post recenti in WordPress utilizzando una serie di metodi diversi.

How to display recent posts in WordPress

Perché aggiungere i post recenti in WordPress?

Se gestite un blog o un sito web WordPress da molto tempo, potreste avere alcuni vecchi articoli che ricevono regolarmente traffico dai motori di ricerca e da altre fonti.

Molti dei visitatori controllano le informazioni che stavano cercando e se ne vanno. Oltre il 75% di questi visitatori non vedrà mai più il vostro sito web.

Per far sì che gli utenti tornino a visitare il vostro sito, dovete fare in modo che trascorrano più tempo sul vostro sito.

Un modo per farlo è mostrare loro altri post recenti che dovrebbero vedere. Questo aiuta gli utenti a scoprire più contenuti sul vostro sito web, il che li porta a trascorrere più tempo sul vostro sito.

Man mano che gli utenti visualizzano più pagine, avete il tempo di convincerli a iscriversi alla vostra newsletter o a fare un acquisto.

Detto questo, vediamo come visualizzare facilmente i post recenti in WordPress utilizzando diversi metodi. Potete cliccare sui link rapidi qui sotto per passare direttamente ai diversi metodi:

Video tutorial

Subscribe to WPBeginner

Se preferite le istruzioni scritte, continuate a leggere.

Metodo 1: Utilizzare il blocco Gutenberg degli ultimi messaggi di WordPress

L’editor di blocchi di WordPress (Gutenberg) ha un blocco integrato per visualizzare gli ultimi post. È possibile aggiungerlo facilmente a qualsiasi post o pagina del sito.

Per utilizzare questo blocco, è sufficiente modificare il post in cui si desidera visualizzare i messaggi recenti. Nella schermata di modifica del post, è necessario aggiungere il blocco “Ultimi messaggi” all’area dei contenuti.

Add latest posts block

È possibile configurare questo blocco in molti modi diversi. Per impostazione predefinita, mostra solo i titoli dei post, ma è possibile personalizzarlo facilmente.

Ad esempio, è possibile attivare e disattivare il contenuto del post nel riquadro di destra. In questo modo si può scegliere se aggiungere il contenuto del post o un estratto accanto al titolo.

È inoltre possibile personalizzare la lunghezza dell’estratto, che per impostazione predefinita è di 55 parole, ma è possibile scegliere qualsiasi valore compreso tra 10 e 100 parole.

Show post content in recent posts

Se si desidera, è possibile visualizzare anche la data e l’autore del post.

È sufficiente attivare le opzioni “Visualizza la data del post” e “Visualizza il nome dell’autore” in Impostazioni dei meta-post.

Display post date and author

È inoltre possibile scegliere esattamente come visualizzare i post. È possibile ordinarli in modo diverso da quello predefinito “dal più recente al più vecchio” e mostrare solo gli ultimi post di una categoria specifica.

Dal pannello delle impostazioni è possibile scegliere il numero di messaggi da visualizzare. Per impostazione predefinita, il blocco mostra 5 messaggi, ma si possono visualizzare da 1 a 100 messaggi.

Sort and filter recent posts

È inoltre possibile visualizzare i post recenti in una griglia di colonne anziché in un elenco.

È sufficiente selezionare l’opzione “Vista griglia” nella barra degli strumenti.

View latest posts in grid view

È possibile personalizzare la griglia utilizzando le impostazioni a destra dello schermo.

Ad esempio, è possibile mostrare immagini in primo piano per i post, ridimensionare le immagini e allinearle di conseguenza.

Show featured images in latest posts

Una volta terminato, è possibile visualizzare l’anteprima del post sul proprio sito web.

Ecco come appare il blocco finito dal vivo sul nostro sito di prova.

Latest posts preview

Metodo 2: Utilizzare il blocco di widget dei messaggi recenti di WordPress

E se si volesse mostrare un elenco degli ultimi post nella barra laterale invece che in una pagina? WordPress è dotato di un widget predefinito per visualizzare i post recenti nella barra laterale del sito o in qualsiasi area predisposta per i widget.

Nella dashboard di WordPress, andare su Aspetto ” Widget e aggiungere il blocco widget “Ultimi messaggi” alla barra laterale.

Add latest post widget block

È quindi possibile personalizzare l’aspetto dei post recenti nella barra laterale.

Ad esempio, WordPress consente di mostrare il contenuto dei post, di visualizzare l’autore e la data del post, di attivare le immagini in evidenza e di ordinare gli ultimi post.

Customize recent posts widget block

Al termine, fare clic sul pulsante “Aggiorna” per memorizzare le impostazioni del widget.

Ecco il widget dal vivo sul blog, con il titolo “Nuovi messaggi” e le date abilitate:

Latest posts in sidebar menu

Metodo 3: Usare il widget dei post recenti con le miniature

Il widget integrato di cui abbiamo parlato sopra è piuttosto limitato.

E se volete visualizzare miniature ed estratti dei vostri post recenti? E se voleste mostrare solo i post di una categoria specifica nella vostra barra laterale?

In questo caso, il plugin Recent Posts Widget With Thumbnails è utile. Fa molto di più delle semplici miniature ed è gratuito.

Per prima cosa, è necessario installare e attivare il plugin WordPress Recent Posts Widget With Thumbnails.

Successivamente, andare alla pagina Aspetto ” Widget e aggiungere il blocco di widget “Messaggi recenti con anteprime”.

Add recent posts with thumbnails widget block

Il widget Messaggi recenti con miniature è dotato di molte opzioni. Vi dà il pieno controllo su come volete visualizzare i post recenti sul vostro sito WordPress.

È inoltre possibile mostrare estratti, mostrare post di categorie specifiche, ignorare i post appiccicati, scegliere il numero di post da mostrare, visualizzare gli autori e altro ancora.

Customize recent posts with thumbnails

Una volta terminato, non dimenticate di fare clic sul pulsante “Aggiorna” per memorizzare le impostazioni.

Ora è possibile visitare il proprio sito web per vedere i post recenti con le miniature.

Recent posts widget with thumbnails preview

Metodo 4: visualizzare i post recenti con uno shortcode

L’utilizzo del blocco “Ultimi messaggi” è sicuramente il modo più semplice per visualizzare i messaggi recenti nei post e nelle pagine di WordPress. Tuttavia, se si sceglie di disabilitare Gutenberg e di mantenere l’editor classico, è possibile utilizzare gli shortcode.

Innanzitutto, installate e attivate il plugin Relevant. Se avete bisogno di aiuto, consultate la nostra guida su come installare un plugin di WordPress.

È uno dei più popolari plugin per WordPress. Sono disponibili diverse opzioni per personalizzare l’aspetto dei post più recenti, come la modifica del titolo, il numero di post, la scelta di visualizzare o meno un’immagine in evidenza, un estratto, la data del post e altro ancora.

Change relevant settings

Quindi, è sufficiente modificare un post o una pagina in cui si desidera visualizzare i post recenti e utilizzare lo shortcode [bws_latest_posts].

Ecco come appariva il nostro elenco di post recenti, utilizzando queste istruzioni:

Display recent posts shortcode

Metodo 5: Visualizzare i messaggi recenti manualmente in WordPress

Gli utenti WordPress più avanzati potrebbero voler aggiungere i post recenti direttamente ai file del loro tema WordPress. Naturalmente, è consigliabile utilizzare un tema figlio per questo scopo, in modo che quando si aggiorna il tema non si perdano le modifiche apportate.

È sempre una buona idea creare un backup prima di modificare i file del tema. Se qualcosa dovesse andare storto, potreste dare un’occhiata al nostro elenco degli errori più comuni di WordPress e a come risolverli.

Il modo più semplice per visualizzare manualmente i post recenti è utilizzare la classe WP_Query integrata. È sufficiente aggiungere questo codice nel punto in cui si desidera visualizzare i post recenti:

<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>

Questo codice visualizza i cinque post più recenti con i loro titoli ed estratti. La classe WP_Query ha molti parametri che consentono di personalizzarla in qualsiasi modo. Per ulteriori informazioni, consultare la documentazione per sviluppatori di WordPress.

Guide di esperti su come raccomandare i post in WordPress

Ora che sapete come visualizzare i post recenti in WordPress, potreste voler vedere altri articoli relativi alla promozione dei contenuti ai vostri lettori.

Speriamo che questo articolo vi abbia aiutato a capire come visualizzare i post recenti in WordPress. Potreste essere interessati anche alla nostra guida su come creare una pagina separata per i post del blog in WordPress e alla nostra scelta dei migliori plugin drag-and-drop per il page builder di WordPress.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

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.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

141 commentiLascia una risposta

  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. Nick NEvsky says

    Hi! Great plugin, thank you!
    Is it possible to have the author listed, instead of the post name?
    Thanks!

  9. 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?

  10. 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

  11. Tushar says

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

  12. 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.

  13. 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.

  14. 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?

  15. 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!

  16. 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.?

  17. 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().

  18. 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

  19. 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.

  20. 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.

  21. 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

  22. 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.

  23. 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?

  24. 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.

  25. 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

  26. 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!

  27. 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.

  28. Mike says

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

    Thanks

  29. 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

  30. 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………….:(

  31. 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.

      Admin

  32. 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.

  33. 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!

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.