Deseja mostrar suas postagens recentes no WordPress? A exibição de publicações recentes ajuda os usuários a descobrir facilmente seu novo conteúdo e a passar mais tempo em seu site.
Você pode adicionar uma lista de suas últimas postagens na barra lateral, após o final do conteúdo da postagem, dentro do conteúdo da postagem com um shortcode, na área do widget do rodapé ou em qualquer outro lugar que desejar.
Neste artigo, mostraremos como exibir posts recentes no WordPress usando uma variedade de métodos diferentes.
Por que adicionar posts recentes no WordPress?
Se você administra um blog ou site WordPress há muito tempo, talvez tenha alguns artigos mais antigos que recebem tráfego regular dos mecanismos de pesquisa e de outras fontes.
Muitos dos visitantes verificarão as informações que estavam procurando e sairão. Mais de 75% desses visitantes nunca mais verão seu site.
Para fazer com que os usuários voltem ao seu site, é preciso garantir que eles passem mais tempo no site.
Uma maneira de fazer isso é mostrar a eles outras publicações recentes que deveriam ser vistas. Isso ajuda os usuários a descobrir mais conteúdo no seu site, o que faz com que eles passem mais tempo no site.
À medida que os usuários visualizam mais páginas, você tem tempo para convencê-los a assinar o boletim informativo por e-mail ou fazer uma compra.
Dito isso, vamos dar uma olhada em como exibir facilmente as publicações recentes no WordPress usando vários métodos. Você pode clicar nos links rápidos abaixo para ir direto aos diferentes métodos:
Tutorial em vídeo
Se você preferir instruções por escrito, continue lendo.
Método 1: Usar o Bloco Gutenberg de Últimos Posts do WordPress
O editor de blocos do WordPress (Gutenberg) tem um bloco integrado para exibir suas postagens mais recentes. Você pode adicioná-lo facilmente a qualquer postagem ou página do seu site.
Para usar esse bloco, basta editar a postagem em que você deseja exibir as postagens recentes. Na tela de edição do post, você precisa adicionar o bloco “Latest Posts” à área de conteúdo.
Há muitas maneiras diferentes de configurar esse bloco. Por padrão, ele mostra apenas os títulos das postagens, mas você pode personalizá-lo facilmente.
Por exemplo, você pode ativar e desativar o conteúdo da postagem no painel direito. Isso permite que você escolha adicionar o conteúdo da postagem ou o trecho ao lado do título.
Você também pode personalizar o tamanho do trecho, que tem como padrão 55 palavras, mas pode escolher qualquer valor entre 10 e 100 palavras.
Se desejar, você também pode exibir a data e o autor da postagem.
Basta ativar as opções “Exibir data de postagem” e “Exibir nome do autor” em Configurações de meta de postagem.
Você também pode escolher exatamente como suas postagens serão exibidas. Você pode ordená-las de forma diferente da predefinida “Mais recente para a mais antiga” e pode mostrar apenas as postagens mais recentes de uma categoria específica.
No painel de configurações, você também pode escolher quantas publicações serão exibidas. Por padrão, o bloco mostra 5 publicações, mas você pode exibir entre 1 e 100 publicações.
Você também tem a opção de exibir suas postagens recentes em uma grade de colunas em vez de uma lista.
Basta selecionar a opção “Grid view” na barra de ferramentas.
É possível personalizar a grade usando as configurações à direita da tela.
Por exemplo, você pode mostrar imagens em destaque para suas postagens, redimensionar as imagens e alinhá-las adequadamente.
Quando terminar, você poderá visualizar a postagem para exibi-la em seu site.
Veja como o bloco finalizado aparece ao vivo em nosso site de teste.
Método 2: Use o bloco de widgets de postagens recentes do WordPress
E se você quiser mostrar uma lista das suas últimas publicações na barra lateral em vez de em uma página? O WordPress vem com um widget padrão integrado para exibir as publicações recentes na barra lateral do seu site ou em qualquer área preparada para widgets.
No painel do WordPress, vá para Appearance ” Widgets e adicione o bloco do widget “Latest Posts” à barra lateral.
Em seguida, você pode personalizar a aparência de suas postagens recentes na barra lateral.
Por exemplo, o WordPress permite que você mostre o conteúdo da postagem, exiba o autor e a data da postagem, habilite imagens em destaque e classifique suas postagens mais recentes.
Quando terminar, clique no botão “Update” (Atualizar) para armazenar as configurações do widget.
Aqui está o widget ao vivo no blog, com o título “New Posts” e as datas ativadas:
Método 3: Use o plug-in Recent Posts Widget With Thumbnails (Widget de postagens recentes com miniaturas)
O widget incorporado mencionado acima é bastante limitado.
E se você quiser exibir miniaturas e trechos com suas postagens recentes? E se você quiser mostrar somente as postagens de uma categoria específica na barra lateral?
Bem, é nesse momento que o plug-in Recent Posts Widget With Thumbnails é útil. Ele faz muito mais do que apenas miniaturas, e é gratuito.
Primeiro, você precisará instalar e ativar o plug-in WordPress Recent Posts Widget With Thumbnails.
Em seguida, vá para a página Appearance ” Widgets e adicione o bloco do widget “Recent Posts With Thumbnails”.
O widget Recent Posts With Thumbnails vem com muitas opções. Ele lhe dá controle total sobre como deseja exibir as postagens recentes no seu site WordPress.
Você também pode mostrar trechos, mostrar postagens de categorias específicas, ignorar postagens fixas, escolher o número de postagens a serem mostradas, exibir autores e muito mais.
Quando terminar, não se esqueça de clicar no botão “Update” (Atualizar) para armazenar suas configurações.
Agora você pode visitar seu site para ver suas postagens recentes com miniaturas.
Método 4: Exibir posts recentes usando um código curto
Usar o bloco “Latest Posts” é definitivamente a maneira mais fácil de exibir posts recentes em posts e páginas do WordPress. No entanto, se você optar por desativar o Gutenberg e manter o editor clássico, poderá usar códigos de acesso.
Primeiro, instale e ative o plug-in Relevant. Se precisar de ajuda, consulte nosso guia sobre como instalar um plug-in do WordPress.
É um dos plug-ins de postagem mais populares para WordPress. Você tem várias opções para personalizar a aparência de suas postagens mais recentes, como editar o título, o número de postagens, selecionar se deseja exibir uma imagem em destaque, um trecho, a data da postagem e muito mais.
Em seguida, basta editar um post ou uma página em que deseja exibir seus posts recentes e usar o shortcode [bws_latest_posts]
.
Veja como ficou nossa lista de postagens recentes, usando essas instruções:
Método 5: Exibir posts recentes manualmente no WordPress
Usuários mais avançados do WordPress podem querer adicionar publicações recentes diretamente aos arquivos de tema do WordPress. É claro que você deve usar um tema filho para isso, de modo que, ao atualizar o tema, não perca as alterações.
É sempre uma boa ideia criar um backup antes de editar os arquivos do tema. Se algo der errado, dê uma olhada em nossa lista dos erros mais comuns do WordPress e como corrigi-los.
A maneira mais fácil de exibir manualmente as postagens recentes é usar a classe WP_Query integrada. Basta adicionar este código onde você deseja exibir as postagens recentes:
<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>
Esse código exibe as cinco publicações mais recentes com seus títulos e trechos. A classe WP_Query tem vários parâmetros que permitem que você a personalize da maneira que desejar. Para obter mais informações, consulte a documentação do desenvolvedor do WordPress.
Guias especializados sobre recomendação de publicações no WordPress
Agora que você já sabe como exibir posts recentes no WordPress, talvez queira ver outros artigos relacionados à promoção de conteúdo para seus leitores.
- Como exibir postagens populares por visualizações no WordPress
- Melhores plug-ins de publicações populares para WordPress (comparados)
- Como exibir posts relacionados no WordPress (passo a passo)
- Melhores plug-ins de posts relacionados para WordPress (comparados)
- Métodos comprovados para promover posts antigos no WordPress
- Como destacar novas postagens para visitantes que retornam no WordPress
- Como exibir postagens aleatórias no WordPress (tutorial fácil)
- Como exibir os posts mais comentados no WordPress
- Como exibir postagens recentes de uma categoria específica no WordPress
- Como aumentar o tráfego do seu blog – a maneira mais fácil
Esperamos que este artigo tenha ajudado você a aprender como exibir posts recentes no WordPress. Talvez você também se interesse por nosso guia sobre como criar uma página separada para publicações de blog no WordPress e por nossa seleção especializada dos melhores plug-ins de criação de páginas do WordPress do tipo arrastar e soltar.
Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.
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!
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.
WPBeginner Support says
Try updating your permalink structure. Simply visit Settings » Permalinks and then click on the save changes button without changing anything.
Administrador
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
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?
John Mason says
Are links to the recent posts widget dofollow links?
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
Rajkumar says
hello,
To display a thumbnail image u can ues
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.
Farhad says
Hello, I used the same shortcut in my site but it not show my recent posts at all, what is the probelm?
WPBeginner Support says
This article shows several ways to display recent posts, which one you tried on your website?
Administrador
Marcio says
Hey, how to display recent posts from another wordpress site?
WPBeginner Support says
You can fetch them using RSS feed. Please see, how to fetch feeds in WordPress.
Administrador
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!
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!
alin dragoescu says
Hello,
Please let me know if it’s posible to show the post list in dropdown?
Nick NEvsky says
Hi! Great plugin, thank you!
Is it possible to have the author listed, instead of the post name?
Thanks!
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?
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
Tushar says
Hi I am new on wordpress, I want to show Client Testimonial using post….How should I do it..? any suggestions please ?
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.
philip says
please how do decrease the number of words showed before the read more link i.e decrease the excerpt
WPBeginner Support says
Please see our guide on How to customize WordPress excerpts (no coding required).
Administrador
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.
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?
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!
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.?
Oliver says
Hi KalanaDe! I guess you already found a solution. In case you did not – here’s a widget that does the job:
https://wordpress.org/plugins/recent-posts-by-category-widget/
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().
Dan says
This worked perfect! Thanks a lot to the author of this article.
Gabriel says
The link to Limit-Post Plugin doesnt work!?
WPBeginner Support says
Thanks for notifying us. We have updated the article with a new code snippet that does not require you to install any plugins. Hope this helps.
Administrador
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
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.
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.
WPBeginner Support says
Change your WP_Query like this:
1-click Use in WordPress
Administrador
Captain Code says
Exactly what I was looking for!
Thank You =)
Actors Alliance says
Where do I input the code to change the number of full posts displayed?
Amanda says
Lovely! Is there a way to make the headers of each post H2 ? And, can I hide a category?
Editorial Staff says
Yes use the second method and wrap it around h2. Use wp_query codex page to look at the parameter for hiding categories.
Administrador
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
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?
Editorial Staff says
Where in the individual posts do you want to show that list? Below post? Sidebar?
Administrador
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).
Editorial Staff says
Go to Appearance > Theme Options. Change the default Layout to content on left.
Ellery Davies says
Hi Syed,
Indeed, this is my current setting. It has always been my setting. Twenty Eleven with “Content on left”.
Editorial Staff says
Hmm that’s weird because that’s what I have and it is working fine.
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 and with the_post_thumbnail ?
Editorial Staff says
Simply add the_post_thumbnail(); and style it however you like.
Administrador
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.
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?
muhabas says
Spent a lot of time to find out this information which works for me 100%. Its very easy and to the point. Thanks…… God bless you.
wanted20 says
Hello. I have a website with 3 subdomains. It’s possible to display in a widget in the main domain the lastest posts from a subdomain?
cwdcreative says
The link to the “limit-post” plugin does not work. Do you have a current link or an alternate?
Thank you!
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.
doodark says
Thanks so much for posting such a useful and concise article. Much appreciated!
YiLiu says
very usefull for me.thanks
Tiago Araujo says
Thank you very much for the post, I was looking for it for a while and found your explanation pretty simple and useful. Code worked just fine for me!
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
Editorial Staff says
You can’t use wp_get_archives for that. You would have to run a loop and add the query_post function with the offset parameter.
Administrador
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
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!
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.
Mike says
Hi, is it possible to show the date before the linked post title when using:
<?php get_archives('postbypost', '10', 'custom', '’, ”); ?>
Thanks
Editorial Staff says
To do that, the better option would be to run a new loop.
Administrador
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
Editorial Staff says
Try reading this article: https://www.wpbeginner.com/wp-tutorials/how-to-create-a-separate-page-for-blog-posts-in-wordpress/
Administrador
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………….:(
Editorial Staff says
Don’t see why it wouldn’t display posts in the order of date. The loop method would only display the most recent ones at the top.
Administrador
Abhijit V. Chaore says
There were few articles around explaining the same thing. But you elaborated the topic with additional information which is very useful. Thanks for your efforts.
seminyak bali says
How about on spesific page – example i make new page called blog, i have try the code but get error,
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.
Administrador
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.
Editorial Staff says
Glad we were able to help
Administrador
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!
Editorial Staff says
Use the Super WordPress loop tutorial instead. You would just need to add the pagination code in there.
Administrador