Como exibir postagens recentes do blog em seu site WordPress - PT

Executamos o código de postagens recentes que vários tutoriais ainda copiam, no WordPress 7.1.3. Ele imprimiu seus próprios comentários na página e listou 6 posta quando solicitado 5. As ferramentas integradas funcionam melhor, but they have traps of their own, and this guide shows where each one bites.

Resposta rápida: use the Latest Posts block wherever the list should go.

  1. Check your theme type. No painel, open Appearance. “Widgets” means a classic theme; “editor” sem “Widgets” means a block theme.
  2. Classic theme: vá para Aparência, then Widgets. Open the Sidebar (or footer) área, click the blue + botão, procurar “Últimas postagens” and add it. Click Update.
  3. Block theme: vá para Aparência, então Editor, then Patterns, and open the Footer template part. Click a block inside the footer’s main column first. Then add Latest Posts and click Save.
  4. In the block’s settings, turn on Display featured image and Display post date. Pick a count under Number of items; a new block shows 5.
  5. Open one of your posts on the live site. If the list shows the post you’re reading, pule para the duplicate fix.

Our test ran on 9 Outubro 2026: WordPress 7.1.3 in WordPress Playground, with Twenty Twenty-Five (quadra) and Twenty Sixteen (clássico). Where a tip wasn’t part of that test, nós dizemos isso.

Which Route Fits Your Theme and the Spot You Want

The tool is nearly always the same block. What changes is where you open it, and that depends on the theme type from step 1.

Where the list goes Classic theme Block theme
Barra Lateral Aparência, then Widgets, Sidebar area No sidebar area by default; build one into a template
Rodapé Aparência, then Widgets, footer area if the theme has one Aparência, então Editor, Patterns, Rodapé
Under every post A widget area the theme prints under posts, or template code Modelos, then Single Posts (often already has a “More posts” Lista)
Inside one post Latest Posts block in the post editor Mesmo
Pagina inicial Definições, então lendo, “Your latest posts” Mesmo

Not sure what changes when a site moves from one theme type to the other? Nosso guia para changing your WordPress theme covers that switch, including what happens to existing widgets.

Sidebar or Footer in a Classic Theme

Classic themes still have widget areas, but the Widgets screen isn’t the drag-and-drop page older guides show. Desde WordPress 5.8, lançado em 20 Julho 2021, widget areas are edited with blocks. In Twenty Sixteen, the screen opened with “Welcome to block Widgets” and listed three areas: Barra Lateral, Content Bottom 1 and Content Bottom 2.

You may find the job already done. On our fresh install, the Sidebar already held a “Postagens recentes” heading with a Latest Posts block under it. WordPress adds that group to new sites, along with Search, Recent Comments, Archives and Categories. So click the existing list and change its settings before you add a second one.

  1. Vá para Aparência, then Widgets, and expand the Sidebar area.
  2. Click the Latest Posts list under “Postagens recentes”, or add one with the + botão.
  3. In the right panel, turn on Display post date and Display featured image, and set Image alignment to Left.
  4. Definir número de itens, then click Update. WordPress confirms with “Widgets saved.”
Captura de tela da barra lateral Twenty Sixteen com um título de Postagens recentes e três links de postagem com datas, um com uma miniatura quadrada.

The default Recent Posts group in Twenty Sixteen, with dates and thumbnails switched on. Note how the floated thumbnail runs over the next widget’s divider line. WordPress 7.1.3, testado no WordPress Playground, 9 Outubro 2026.

Looking for the old “Postagens recentes” widget instead? It’s gone from this screen. Procurando “Postagens recentes” in the block inserter returned only the Latest Posts block. WordPress’s own code hides the old widget from the Legacy Widget block, so on this screen the block is the only route.

If you really want the old screen back, the official Classic Widgets plugin restores it on classic themes (we didn’t install it for this test). Its WordPress.org page promises support “para 2024, or as long as is necessary”, and it was last updated on 8 dezembro 2025. Funciona, but it’s a step backwards. The old widget offers a title, a post count and a date switch, e nada mais: no thumbnails.

Block themes have no widget areas, so there’s no Widgets screen to open. The footer is a template part, built from blocks and edited in the Site Editor. Twenty Twenty-Five offers three: Rodapé, Footer Columns and Footer Newsletter. Its templates use the one called Footer.

Here’s the part that tripped us up twice. With nothing selected, a + button in the top bar adds the block at the very end of the template part. That’s outside the group that gives the footer its padding. No site ao vivo, our list sat flush against the left edge of the window.

Our second try went into the footer’s right-hand column, next to an empty Spacer. That column measured 0 pixels de largura, because the left column takes the full width. The post titles came out one letter per line. Picking a block inside the main column first fixed it.

  1. Vá para Aparência, então Editor, then Patterns. Em partes do modelo, click Footer, então o design chamado “Rodapé”.
  2. In the footer, click the line of text under your site title (the Site Tagline block). The breadcrumb at the bottom should end in Columns, Coluna, Site Tagline.
  3. Clique no + button in the top bar, procurar “Postagens recentes” ou “Últimas postagens” and pick Latest Posts. It goes in right after the block you selected.
  4. Set the options in the right panel, then click Save. WordPress shows “Template part updated.”
Two-panel screenshot: Latest Posts settings with post date and featured image on and left image alignment, beside the resulting list in a site footer.

Deixou: the image settings we used. Direita: the list under the site title in the Twenty Twenty-Five footer, where Hello world! has no featured image. WordPress 7.1.3, testado no WordPress Playground, 9 Outubro 2026.

Remember that a template part appears on every page that uses it. Our footer list showed on the homepage, on posts and on the Sample Page. That’s usually the point of a footer, but it also means the list will appear under each post, which leads to the next problem.

Want a sidebar in a block theme? There isn’t a sidebar area to fill. You’d add a Columns block to the template itself (Modelos, then Single Posts) and put Latest Posts in the narrow column. We didn’t build one in our test. It’s a template edit, so try it on a copy of your site first.

The List That Shows the Post You’re Reading

Open your newest post and look at your recent-posts list. Is that same post in it? It will be whenever the post is one of your newest few. Older posts drop out of the list on their own.

The footer list on our “Cafe stop guide” post included the cafe stop guide itself. The Latest Posts block has no setting to leave out the current post. Its code in WordPress has no such filter either, so a list placed inside a post behaves the same way.

Twenty Twenty-Five has a second source of duplicates. Its Single Posts template ends with a “More posts” Lista, a Query Loop set to 4 Itens. On our test post it showed 5 Itens, não 4. A sticky post from 1 October sat on top, older than everything under it, and the post being read sat third.

Screenshot of a five-item More posts list with a sticky post dated October 1 on top and the post being read outlined third.

More posts on our cafe stop guide lists 5 Itens, não 4, led by a pinned post from 1 Outubro, with the post itself outlined. WordPress 7.1.3, testado no WordPress Playground, 9 Outubro 2026.

Por quê 5? A sticky post is one you’ve pinned to the top of the blog in the post’s settings. With Sticky posts left on “Incluir”, the Query Loop adds pinned posts on top of its normal count. Each pinned post that isn’t already in the list makes it one item longer.

WordPress 7.1 (out since 19 agosto 2026) gave the Query Loop block an “Exclude current” troca. Versions 7.0 and earlier have no such switch, so older guides send you to code for this.

  1. Vá para Aparência, então Editor, então Modelos, and open Single Posts.
  2. Clique no “More posts” Lista. The right panel says it’s a pattern; click Edit pattern.
  3. Click the list again so the Query Loop is selected.
  4. Set Sticky posts to Ignore. Under Filters, turn on Exclude current.
  5. Clique em Salvar. WordPress shows “Template updated.”
Captura de tela de dois painéis das configurações do Query Loop: Sticky posts set to Ignore, and the Exclude current switch turned on under Filters.

The two Query Loop settings that fixed it: Sticky posts on Ignore, and Exclude current under Filters. WordPress 7.1.3, testado no WordPress Playground, 9 Outubro 2026.

After the change, the same post showed exactly 4 other posts, newest first. “Ignore” keeps sticky posts in their normal date order. “Excluir” removes them from this list altogether, which is right if your sticky post is an announcement.

We tested Exclude current in the Single Posts template only. For a footer or sidebar list, there are two other routes. On a classic theme, the thumbnail plugin below has a “Do not show the current post?” caixa. The shortcode in the code section skipped the current post when we placed it inside a post; we didn’t try it in a footer.

On the Homepage or Inside a Post

A new WordPress site already shows recent posts on the homepage. Under Settings, então lendo, “Sua página inicial exibe” starts on “Your latest posts”. The number shown follows the “Número de postagens recentes mostradas nas páginas de arquivo” campo, que começa em 10.

Using a static homepage instead? Add a Latest Posts block to that page, below your own content. Giving the blog its own page with page numbers is a bigger job, with its own settings and menu steps.

Inside a single post, um breve “Read next” list works well near the end. Add Latest Posts from the + button and keep it to 3 Itens. Filter it by the post’s category, so readers see related posts rather than whatever went out yesterday.

Thumbnails, Excerpts and Other Display Options

The Latest Posts block covers most display needs without a plugin. Here’s what its settings offered in 7.1.3:

  • Imagem em destaque: Thumbnail, Medium or Large source size, plus custom width and height or 25% para 100% predefinições. Alignment is None, Deixou, Center or Right, and a switch makes the image a link.
  • Post content: an excerpt or the full post. The excerpt runs from 10 para 100 words and starts at 55.
  • Post meta: author name and post date, each with its own switch.
  • Sorting and filtering: newest or oldest first, A to Z or Z to A, categorias, one author, e 1 para 100 Itens.
  • Layout: list view or grid view, from the block toolbar.

A thumbnail comes from each post’s featured image, and the default Thumbnail size gave us 150 de 150 píxeis. A post without a featured image shows no image at all. Nosso “Hello world!” post sat bare above two posts with pictures, which looks broken in a sidebar. Set a featured image on every post, or the list will look uneven.

For a footer, keep it tight: 3 Itens, date on, excerpt off. Every extra line pushes your footer links further down.

The Code Route for Theme Developers

The snippet this page carried until now mixes HTML with PHP like this (other guides still carry it):

<ul>
// Defines your WP Query Parameters
<?php $the_query = new WP_Query( 'posts_per_page=5' ); ?>

// Starts your WP Query
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

// Displays the Post Title with Hyperlink
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>

// Displays the Post Excerpt
<li><?php the_excerpt(__('(more…)')); ?></li>

// Repeat the process and reset on limit
<?php
endwhile;
wp_reset_postdata();
?>
</ul>

We pasted it, inalterado, into a page on our test site. Three things went wrong:

  • The lines starting with // sit outside the PHP tags, so they’re plain text. Visitors saw “// Displays the Post Title with Hyperlink” between every post.
  • It asked for 5 posts and printed 6. A query built this way counts as a homepage query, and WordPress adds sticky posts on top of those.
  • The title and the excerpt land in separate list items, tão 6 posts became 12 bullets.
Screenshot of a page where old recent posts code printed comment lines such as // Displays the Post Excerpt between the post links.

Output of the 2021 snippet: its comment lines show up as page text and the sticky post leads the list. Twenty Sixteen theme, WordPress 7.1.3, testado no WordPress Playground, 9 Outubro 2026.

Here’s the version we tested instead. It’s a tiny plugin, so it survives a theme switch, and it adds a [my_recent_posts] shortcode you can use anywhere:

<?php
/**
 * Plugin Name: My Recent Posts
 * Description: Adds the [my_recent_posts] shortcode.
 */

function my_recent_posts_shortcode( $atts ) {
	$atts = shortcode_atts( array( 'count' => 5 ), $atts, 'my_recent_posts' );

	$query = new WP_Query(
		array(
			'posts_per_page'      => (int) $atts['count'],
			'post__not_in'        => is_singular() ? array( get_queried_object_id() ) : array(),
			'ignore_sticky_posts' => true,
			'no_found_rows'       => true,
		)
	);

	if ( ! $query->have_posts() ) {
		return '';
	}

	$html = '<ul class="my-recent-posts">';
	while ( $query->have_posts() ) {
		$query->the_post();
		$html .= sprintf(
			'<li><a href="%s">%s%s</a></li>',
			esc_url( get_permalink() ),
			get_the_post_thumbnail( null, 'thumbnail' ),
			esc_html( get_the_title() )
		);
	}
	wp_reset_postdata();

	return $html . '</ul>';
}
add_shortcode( 'my_recent_posts', 'my_recent_posts_shortcode' );

To install it, save the code as my-recent-posts.php in a folder called my-recent-posts dentro wp-content/plugins. Then activate “My Recent Posts” under Plugins. We added [my_recent_posts count="3"] to a post with a Shortcode block. It listed 3 other posts, left out the post itself and ignored the sticky post. Posts with a featured image got a 150-pixel thumbnail.

Where does the shortcode go? Em um tema de bloco, put a Shortcode block in a template or template part. Em um tema clássico, add a Shortcode block to a widget area. In a classic theme’s PHP template, ligar echo do_shortcode( '[my_recent_posts]' ); em vez de. Use a child theme for template edits, or the next theme update will wipe them.

Plugins: Two Old Favourites Are Closed

You don’t need a plugin for a basic list. One earns its place only when you want features the block lacks. The catalogue has also changed since most guides were written.

  • Recent Posts Widget With Thumbnails: still maintained (versão 7.2.0, Atualizada 13 setembro 2026, tested up to 7.1.3). It adds what Latest Posts lacks: “Do not show the current post?”, sticky post controls and a default thumbnail for posts without one. It’s built for widget areas, so it suits classic themes only. On the block Widgets screen it appeared as “Recent Posts With Thumbnails”.
  • Display Posts: the shortcode plugin this page used to recommend. Its last update was 14 Outubro 2024, and WordPress.org lists it as tested up to 6.6 só.
  • Recent Posts Widget Extended: fechado, and no longer available to download (detalhes abaixo).
  • Smart Recent Posts Widget: closed on 26 abril 2026 for a guideline violation, and the directory calls the closure permanent.

WordPress.org closed Recent Posts Widget Extended on 4 setembro 2025 for a security issue, so any site still running it gets no further fixes. If a guide still points you to it, that guide predates the closure. Both closed plugins appear on pages that rank for this topic today.

Recent Posts Not Showing Right? Verifique estes

  • The current post appears in the list: Latest Posts can’t exclude it. Use a Query Loop with Exclude current (WordPress 7.1 ou mais tarde), the thumbnail plugin, or the shortcode.
  • One more post than you set: a sticky post. Set Sticky posts to Ignore or Exclude in the Query Loop.
  • The list hugs the left edge of the screen: it was added outside the footer’s group. Delete it, select a block inside the footer first, and add it again.
  • Titles stack one letter per line: the column is too narrow, often an empty spacer column. Move the block to a wider column.
  • Não “Postagens recentes” widget in the list: expected since block widgets. Procurar “Últimas postagens” em vez de.
  • Some posts have no picture: they have no featured image. Add one in the post’s sidebar.
  • New post missing: it may be scheduled or a draft, or a cache is serving an older copy. Limpe o cache, then check in a private browser window.

perguntas frequentes

Why is the post I’m reading in my recent posts list?

The Latest Posts block always lists the newest posts, including the one on screen. It has no setting to skip it. Switch to a Query Loop and turn on Exclude current, which arrived in WordPress 7.1. On older versions, use Recent Posts Widget With Thumbnails or a small shortcode.

How do I add recent posts to the sidebar in a block theme?

Block themes don’t have widget areas, so there’s no sidebar to drop it into. Add a Columns block to the template under Appearance, então Editor, então Modelos. Put Latest Posts in the narrow column. Twenty Twenty-Five already lists recent posts under each post, so you may not need a sidebar at all.

Where did the Recent Posts widget go?

Desde WordPress 5.8, widget areas use blocks, and WordPress hides the old Recent Posts widget. The Latest Posts block replaces it, and searching “Postagens recentes” in the inserter finds it. The Classic Widgets plugin brings the old screen back on classic themes.

Can I show recent posts with thumbnails without a plugin?

sim. Turn on Display featured image in the Latest Posts block and pick a size and alignment. Each post needs a featured image, or it shows none. Only use a plugin if you want a default image for posts without one.

What to Set Up First

Start with the Latest Posts block in your sidebar or footer; on many sites, that’s the whole job. Under a post, use a Query Loop with Exclude current. Keep the code for when you need full control of the markup. Prefer to rehearse on a throwaway site? We tested in WordPress Playground, a free copy of WordPress that runs in your browser. It’s one of the routes covered in how to blog on WordPress before buying a domain.

Pesquisado e escrito por:
Editores de ComoHospedar
HowToHosting.guide fornece conhecimento e insights sobre o processo de criação de blogs e sites, encontrar o provedor de hospedagem certo, e tudo o que vem no meio. Consulte Mais informação...

Deixe um comentário

seu endereço de e-mail não será publicado. Os campos obrigatórios estão marcados *

Este site usa cookies para melhorar a experiência do usuário. Ao usar nosso site, você concorda com todos os cookies de acordo com nosso Política de Privacidade.
Eu concordo
Em HowToHosting.Guide, oferecemos análises transparentes de hospedagem na web, garantindo a independência de influências externas. Nossas avaliações são imparciais, pois aplicamos padrões rigorosos e consistentes a todas as avaliações.
Embora possamos ganhar comissões de afiliados de algumas das empresas apresentadas, essas comissões não comprometem a integridade de nossas avaliações nem influenciam nossas classificações.
Os ganhos do afiliado contribuem para cobrir a aquisição de contas, despesas de teste, manutenção, e desenvolvimento do nosso site e sistemas internos.
Confie em howtohosting.guide para obter informações confiáveis e sinceridade sobre hospedagem.