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

Så här displayed du senaste inlägg i WordPress

Precis som WPBeginner visar många populära bloggar en lista över de senaste inläggen. Det beror på att visning av senaste inlägg är ett bra sätt att hålla besökarna engagerade och komma tillbaka för mer.

När människor ser ditt senaste och bästa innehåll är det mer sannolikt att de klickar, läser och spenderar tid på att utforska din webbplats. Det gör att din webbplats känns fräsch och spännande.

Det bästa är att du kan lägga till dessa listor över senaste inlägg nästan var som helst på din WordPress-webbplats, t.ex. i sidofältet, i slutet av en artikel eller till och med i sidfoten.

I den här artikeln visar vi dig några enkla sätt att lägga till en lista över senaste inlägg på din webbplats, oavsett var du vill att den ska visas. Gör dig redo att hålla dina besökare hooked på ditt fantastiska innehåll.

How to display recent posts in WordPress

Varför lägga till senaste inlägg i WordPress?

Om du har run en WordPress blogg eller website under en längre tid, så kanske du har några äldre artiklar som får regelbunden trafik från search engines och andra källor.

Många av besökarna kommer att kontrollera den information de letade efter och lämna. Mer än 75% av dessa visitors kommer aldrig att se your website igen.

För att få användare att komma tillbaka till din website måste du se till att de tillbringar mer tid på din website.

Ett sätt att göra detta är att visa dem andra senaste inlägg som de borde se. Detta hjälper användare att upptäcka mer content på din website, vilket leder till att de spenderar mer tid på din website.

När användarna viewar fler pages får du tid att övertyga dem om att anmäla sig till ditt nyhetsbrev eller göra ett köp.

Med detta sagt, låt oss ta en titt på hur du enkelt kan visa senaste inlägg i WordPress med hjälp av flera metoder. Du kan klicka på snabblänkarna under för att hoppa direkt till olika metoder:

Video Tutorial

Subscribe to WPBeginner

Om du föredrar skriftliga instruktioner är det bara att fortsätta läsa.

Metod 1: Använd WordPress senaste inlägg Gutenberg Block

WordPress Block Editor (Gutenberg) har ett built-in block för att visa dina senaste post. Du kan enkelt add to detta till alla posts eller pages på din site.

För att använda detta block, redigera helt enkelt det post där du vill visa senaste inlägg. På vyn för edit av post måste du add to blocket ”Latest Posts” till content area.

Add latest posts block

Det finns många olika sätt du kan konfigurera det här blocket. Som standard visar det bara rubrikerna på posterna, men du kan enkelt customize det.

Till exempel kan du toggle post content på och av i den högra rutan. Detta gör att du kan välja att add post content eller excerpt nästa inlägg till titeln.

Du kan också customize längden på excerptet, som standard är 55 ord, men du kan välja valfritt värde mellan 10 och 100 ord.

Show post content in recent posts

Om du vill kan du också visa postdatum och författare till posten.

Aktivera bara alternativen ”Display post date” och ”Display author name” under Metadata för inlägg Settings.

Display post date and author

You kan också välja exakt hur dina posts ska visas. You can order them differently from the standard ”Newest to Oldest”, and you can show only the latest posts from a specific category.

Från panelen Settings kan du också välja hur många posts som ska visas. Som standard visar blocket 5 posts, men du kan visa allt mellan 1 och 100 posts.

Sort and filter recent posts

Du har också alternativet att visa dina senaste inlägg i ett column grid snarare än en lista.

Välj helt enkelt alternativet ”Grid view” i toolbaren.

View latest posts in grid view

Du kan customize gridden med hjälp av settings till höger på vyn.

Till exempel kan du visa featured images för dina inlägg, resize bilderna och justera dem i enlighet med detta.

Show featured images in latest posts

När du är slutförd kan du förhandsgranska posten för att se den på din website.

Så här ser det slutförda blocket ut Live på vår test site.

Latest posts preview

Metod 2: Använd WordPress Widget Block för senaste inlägg

Tänk om du vill visa en lista över dina senaste posts i din sidebar istället för på en page? WordPress levereras med en built-in standardwidget för att visa senaste inlägg i din sites sidebar eller något annat widget-klart area.

I din WordPress dashboard, gå till Appearance ” Widgets och add the ’Latest Posts’ widget block till din sidebar.

Add latest post widget block

You can then customize the appearance of your recent posts in the sidebar.

WordPress låter dig till exempel visa inläggets content, auktorisera inlägget och visa datum, aktivera featured images och sortera dina senaste inlägg.

Customize recent posts widget block

När du är klar klickar du på knappen ”Update” för att lagra dina inställningar för widgetar.

Här är widgeten live på bloggen, med titeln ”New Posts” och datum aktiverade:

Latest posts in sidebar menu

Metod 3: Använd widget för senaste inlägg med inläggsminiatyr-plugin

Den built-in widget som vi nämnde ovan är ganska limit.

Vad händer om du vill visa inläggsminiatyrer och excerpt med dina senaste inlägg? Vad händer om du bara gillar att visa posts från en viss kategori i din sidebar?

Det är då pluginet Recent Posts Widget With Thumbnails kommer väl till pass. Det gör mycket mer än bara thumbnails, och det är gratis.

Först måste du installera och aktivera pluginet WordPress Recent Posts Widget With Thumbnails.

Gå sedan till sidan Appearance ” Widgets och lägg sedan till widgetblocket ’Senaste inlägg med inläggsminiatyrer’.

Add recent posts with thumbnails widget block

Widgeten Senaste inlägg med inläggsminiatyrer kommer med många alternativ. Den ger dig full control över hur du vill displayed senaste inlägg på din WordPress site.

Du kan också visa excerpt, visa inlägg från specifika kategorier, ignorera (fast)klistrade inlägg, välja antal inlägg som ska visas, auktoriseringar med mera.

Customize recent posts with thumbnails

När du är klar, glöm inte att klicka på knappen ”Update” för att lagra dina inställningar.

Du kan nu besöka din website för att se dina senaste inlägg med thumbnails.

Recent posts widget with thumbnails preview

Metod 4: Visa senaste inlägg med hjälp av en shortcode

Att använda blocket ”Senaste inlägg” är definitivt det enklaste sättet att visa de senaste inläggen i WordPress inlägg och pages. Men om du väljer att inaktivera Gutenberg och behålla Classic Editor kan du använda shortcodes istället.

Först installerar och aktiverar du det relevanta pluginet. Om du behöver hjälp, vänligen se vår guide om hur du installerar ett plugin för WordPress.

Det är ett av de mest populära tillägg för post för WordPress. Du får flera options för att customize utseendet på dina senaste inlägg, som att editera rubriken, antalet inlägg, välja om du vill visa en featured image, excerpt, inläggsdatum, och mer.

Change relevant settings

Därefter redigerar du helt enkelt ett inlägg eller en page där du vill visa dina senaste inlägg och använder sedan shortcode [bws_latest_posts].

Så här såg vår lista över senaste inlägg ut med hjälp av dessa instruktioner:

Display recent posts shortcode

Metod 5: Display senaste inlägg manuellt i WordPress

Mer avancerade WordPress-användare kanske vill add senaste inlägg direkt till sina WordPress-temafiler. Naturligtvis bör du använda ett barntema för detta så att du inte förlorar dina ändringar när du uppdaterar ditt tema.

Det är alltid en bra idé att skapa en backup innan du editerar dina theme-filer. Om något går fel kan du ta en titt på vår lista över de vanligaste WordPress error och hur du fixar dem.

Det enklaste sättet att manuellt visa senaste inlägg är att använda den built-in WP_Query-klassen. Lägg bara till den här koden där du vill visa de senaste inläggen:

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

Den här koden visar de fem senaste inläggen med deras titlar och excerpt. WP_Query-klassen har massor av parametrar som gör att du kan customize den på vilket sätt du gillar. Mer information finns vänligen i dokumentationen för utvecklare av WordPress.

Expertguider om att rekommendera publicerade posts i WordPress

Vi hoppas att den här artikeln har hjälpt dig att lära dig hur du visar de senaste inläggen i WordPress. Du kanske också är intresserad av några andra artiklar som handlar om att marknadsföra innehåll till dina läsare:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

141 kommentarerLämna ett svar

  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. Jiří Vaněk says

    I would like to post these recents at the end of each article. But there are already more than 1000 of them. It doesn’t make sense to do it manually. Is it possible to take the php code, insert it into WPCode and use the embed code at the end of each article? Will it work like this?

    • WPBeginner Support says

      There are some options in the plugin settings to limit the categories but at the moment the plugin does not have a modifier like that for the shortcode.

      Administratör

  3. Bernie says

    Thanks for lots of great advice!

    I have been spending days so far, to solve a challange here:

    Im using the Twenty Twenty-Three template.

    Using Gutenberg.

    Created a 2nd column where i would like to place a list of the latest posts by CURRENT author, incl. thumbnail, except etc.

    I can only find this solution in plugins with widgets, and as far as I understand this Gutenberg thing, widgets cant be used here.

    Any idea how to solve this?

    • WPBeginner Support says

      If you are manually adding it to each post, there is a latest posts block that gives the option to limit the posts listed by author and a few other sorting options that you can use as well!

      Administratör

  4. Matt says

    How to enable a link to more pages/posts? The widget only says up to 100, but how to paginate etc if there are 1000 or more?

    • WPBeginner Support says

      We do not recommend having more than 100 posts in a widget due to that being difficult for most users to read through for its space. If you are displaying that many posts we would recommend displaying it on a page or something similar.

      Administratör

  5. Jack Yasgar says

    When I use the WordPress Latest Posts Gutenberg Block, it displays all the texts of the posts. In the preview when I add it to the page, it looks fine, with the ”Read More”, but when you actually preview or publish the page, all the text is displayed and it looks terrible. This is on Version 5.9.1. Any suggestions or is it just a bug?

    • WPBeginner Support says

      You would want to check the settings for your widget as that should be where you can customize how your widget is displayed. If it is not following those settings then you would likely want to reach out to the support for your theme in case it is overriding your settings.

      Administratör

    • WPBeginner Support says

      The simplest method would be to add a category to your menu and that would link to a category page that would list your most recent posts in that category.

      Administratör

  6. Sean says

    I’m using ’Display Posts’ and love it. I run a gardening website so if a post is called ’How to Grow Beetroot’, is there any way by using Display Posts that the only part of the title that is displayed is ’Beetroot’?

    Thank you

    • WPBeginner Support says

      The plugin by default does not change your post titles. You would want to reach out to the plugin’s support if you wanted that functionality

      Administratör

  7. Lucy says

    I can’t seem to get the Read More to appear in the published version. It appears in the editor but when I publish, it is gone. I’m using Astra theme.

    • WPBeginner Support says

      You would want to check for if you need to enable excerpts with your specific theme for it to display how you are wanting.

      Administratör

  8. Hamza says

    Hi, When I click on the ”Read more..” on a post on Recent Posts, it does not to go to that specific post page rather it loads the home page.

    Appreciate if you can help on this.

    Thanks

    • WPBeginner Support says

      It would depend on what method you are using for possible issues and solutions.

      Administratör

  9. Julian says

    This was really helpful thanks. Just a correction to note, in the last code snippet the comments are using // but they’re not actually in the php so they will show up if you use this code as-is.

  10. Michael Robinson says

    Hi, I”m still lost. My posts still don’t show up on my homepage, I have content blocks set up on my homepage and using Guterberg to set up the content. When I publish the post. It does not show up on my Homepage feature posts grid. There is something I am not getting.

    • WPBeginner Support says

      You may want to clear any caching on your site to ensure your caching is not preventing the changes from being seen.

      Administratör

    • WPBeginner Support says

      You can use the new latest post block and use the built-in grid option in the block’s options

      Administratör

    • WPBeginner Support says

      It would depend on why you want to do that. If you want the entire content of a post to be visible to a user it would normally be best to link to the post you want to show so your users can read from the source.

      Administratör

  11. Sarah says

    Hello – I am trying to figure out why the Recent Posts widget (the basic one) is excluding my most recent post. I would like that to show. Is there custom CSS I could add to make it show? or can I edit the code?

  12. Ata says

    Thank you for the useful post.
    I have a question. What if I want to display recent posts on front page categories wise. Like recent posts should appear on the front page under a particular category.
    Is it possible?

  13. Arif says

    Awesome as always. When I found wpbeginner is sharing on this topic I was like . But my question is placing post widget on homepage is beneficial or it’s just easy to navigate? Can it help with seo perspective? Can it help with the ranking? Your response highly appreciated

    • WPBeginner Support says

      Making your site easier to navigate can improve your SEO as well as making it easier for your users to continue navigating through your site.

      Administratör

  14. Rajiv Dave says

    Thanks for recent post articles. I was trying so much but now its so easy to work just adding adding it. Thanks for sharing

  15. Trang says

    When I tried to edit the page that’s supposed to display blog posts, the editor disappears wit this notice: ”You are currently editing the page that shows your latest posts”. Does anyone have this same problem as me?

    • WPBeginner Support says

      The Blog page is automatically generated by your theme so you will not have the option to edit it directly unless you have a theme specific setting to edit it.

      Administratör

  16. Nikos Tzortzis says

    HI…..i just started using WP and i need some help! i want to publish articles from 3 different categories to 3 different pages.how can i make a page point to an article category?

  17. Rob says

    Is there a way to customize the way post titles are displayed? I don’t want to display the full title of the post or page, just the keywords… much like you shorten the slug for your url. Actually this is exactly what I’m looking for, to display the slug as a link, and not the entire page title. Ideas?

  18. Bryan Free says

    Great article, When I use the Recent post widget and set it to only display a category my sticky posts do not work. Have you encountered this before or know of a solution?

  19. eyllan8547 says

    Hi, thanks for this complete article.

    I have a doubt, if I have my wordpress integrated with Magento, can I use magento within the short code to put the last entries in my magento house?

  20. Mankirat Deep Kaur says

    The short code to display recent posts with thumbnails does not work… only shows the posts title not the thumbnails… how to fix this.??? please reply…:(

  21. Kevin says

    Hi,

    I am intending on adding the latest posts on my homepage, but I want a different section for the latest post to display on it’s own;

    and another section under this designed differently for the latest posts that range from 2-5. (The 2nd, 3rd, 4th and 5th post).

    What is the shortcode php for this to add to my theme template.

    Many thanks.

  22. James Gielow says

    Hello,

    I have post shortcode on my page:

    I’ve tweaked it a little bit as follows:

    [display-posts posts_per_page=”100″ include_excerpt=”false” image_size=”large” wrapper=”div” orderby=”comment_count”]

    I’m noticing that the spacing in between the posts is cutting off the titles and it makes the page look sloppy. What code can I add to add a little space after each post preview?

    thanks in advance!
    James

  23. Adam says

    Love the idea, the only thing I don’t like is the display.

    So it’s great how it has the thumbnail, title, excerpt, etc but the way the title and excerpt are positioned…I think they should be inline with the thumbnail, not at the bottom of it…it looks awkward and unappealing…any way to make it inline?

  24. Kenneth says

    Please help me with this
    How to display recently post in a post on phone version?
    Reply please… Thanks

  25. djafa says

    Hi, I put [display-posts posts_per_page=”5″ post_type=”page”] on my post, but not working, can you help how to find the problem?

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

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

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

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

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

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

  32. Nick NEvsky says

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

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

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.