Você não precisa de consultas personalizadas ou chamadas ao banco de dados apenas para obter uma lista de posts recentes. De fato, há uma função incorporada ao WordPress que faz exatamente isso. Ela se chama wp_get_archives(). Talvez você reconheça essa função como uma forma de exibir arquivos mensais, mas, com alguns parâmetros, é possível modificá-la para exibir uma lista de posts do WordPress publicados recentemente. Aqui está o código:
<?php wp_get_archives('title_li=&type=postbypost&limit=10'); ?>
O que isso fará é remover qualquer formatação adicionada pelo WordPress e exibir uma boa lista das 10 publicações mais recentes, cada uma em sua própria tag <li>.
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?
Muchas gracias!!!! Thank you very much!!!! Just what I was looking for!
Saludos desde Spain 😉
Sara
Thanks! That solved my problem in 2 seconds.
Thanx Leland – just in the nick of time
*Love ur site btw 😀
M.?
I’ve implemented it on my about page here: http://www.webdesign-bureau-of-mauritius.com/web-design-mauritius
It works like a charm. Thanks for this!
Can you also tell the system to display the excerpt for the post? or just a teaser?
Okay. All this code does is display a very simple list of recent posts. The markup is similar to this:
<ul>
<li><a href="http://example.com/recent-post-3">Latest One</a></li>
<li><a href="http://example.com/recent-post-2">2nd Latest Post</a></li>
<li><a href="http://example.com/recent-post-1">3rd Latest Post</a></li>
</ul>
If you want anything else (thumbnails, character counts, whatever) that would require a custom loop and I can’t really go over each specific case in the comments here.
How do I do this and also have thumbnails? Very small thumbnails. 35px X 35 px. Google is annoying me sending me round in circles all day long. They’re useless lol.
Well I await your useful reply.
Thanks.
Oh wow this is easy 😀 Thanks for this great article!
BTW, has anyone come across functions to merge both recent post and page update in chronological order?