---
title: "How to Add Search Bar for Posts in WordPress?"
url: https://nexterwp.com/docs/add-search-bar-for-posts-in-wordpress/
date: 2024-12-02
modified: 2026-09-22
lang: en
author: "Aditya Sharma"
description: "A blog search that returns your privacy policy and three product pages is not much use to a reader looking for an article. Restricting the Search Bar to posts is..."
image: https://nexterwp.com/wp-content/uploads/2024/12/How-to-Add-Search-Bar-for-Posts-in-WordPress_-1024x519.jpg
word_count: 512
---

# How to Add Search Bar for Posts in WordPress?

## Key Takeaways

- Nexter Blocks Search Bar restringe la búsqueda a entradas cuando el campo de filtro usa post type y se elige Post, y una misma consulta devuelve 4 resultados frente a 15 cuando no está restringida.
- Nexter Blocks Search Bar busca solo títulos por defecto, y al desactivar los campos de búsqueda cae en la consulta propia de WordPress; con el mismo término, pasa de 4 coincidencias por título a 15 resultados en todos los tipos.
- Nexter Blocks Search Bar solo muestra entradas publicadas, no incluye borradores ni privadas, y el ajuste Show All Result en la versión 5.0.6 muestra tres marcadores vacíos sin título, miniatura ni enlace.

A blog search that returns your privacy policy and three product pages is not much use to a reader looking for an article.

Restricting the Search Bar to posts is a single setting, and it is the one that makes the results feel deliberate.

*For every Search Bar setting in one place, see the [Search Bar guide](https://nexterwp.com/docs/add-a-search-bar-in-wordpress/).*

[LIVE BLOCK LINK](https://nexterwp.com/nexter-blocks/builder/wordpress-ajax-search-bar/)

## Before You Start

- **Edition:** Free. Measured with Nexter Blocks Pro deactivated, the Search Bar renders identically — form, input, dropdowns, suggestions and results all work without Pro.- **Block to enable:** Search Bar, switched on under **Nexter > Blocks** in your WordPress dashboard.- **Published content to find.** The block searches your real posts, so a site with nothing published returns nothing.

## Steps

- Select your **Search Bar** block.

![The Search Bar block](https://nexterwp.com/wp-content/uploads/2024/12/searchbar-field-post.png)

- Add a **filter field** with **post type** as its source, and choose **Post**.

![Choosing post as the searched type](https://nexterwp.com/wp-content/uploads/2024/12/searchbar-ajax-search.png)

- Publish and search for the title of an article you know is live.

![Searching posts only](https://nexterwp.com/wp-content/uploads/2024/12/searchbar-field-post-demo.gif)

## How It Behaves

- **The post type is written into the query before it runs.** Measured: restricted to posts, a term returned 4 results; the same term unrestricted returned 15 across all types.- **The dropdown lists every type you add, plus an All entry.** Measured with post and page selected, the dropdown rendered 3 options.- **Each option can show a count** of how many published items that type has.- **Only the title is searched by default.** Measured: with the default settings a term matched 4 posts by title; switching the search fields off entirely fell through to WordPress's own query and matched 15.- **It degrades to an ordinary search.** The block renders a real `<form method="get">` pointing at your site root, so with JavaScript disabled the bar still submits and lands on WordPress's own search results.- **The excerpt line only appears when the post has one.** Measured: posts with an empty excerpt render a card with no excerpt at all, which can make a result list look uneven.

## Limitations

- **Only published posts are searched.** Drafts and private posts never appear, which is correct but surprises people testing with a draft.- **Adding a second type widens the search again.** If you want posts only, add only posts.- **The count beside each option is a total, not a result count.** It tells the visitor how much content exists, not how much matches what they typed.- **Show All Result does not currently render usable cards.** Measured on 5.0.6: the pre-loaded list renders three empty placeholders with no title, thumbnail or link, and ignores the result count you set. Reported to the developers. Leave it off and let the visitor search.

## Troubleshooting

### Pages are still showing up

The filter field probably has more than one type selected. Remove everything except Post.

### The dropdown is not rendering at all

A filter field needs a source and at least one selection. With the source set but nothing chosen, nothing renders.

### An article is missing from the results

By default only the title is matched. Turn on content matching if you want the body searched too.

## Related Docs

- [Add a search bar in WordPress](https://nexterwp.com/docs/add-a-search-bar-in-wordpress/)- [Search by post category](https://nexterwp.com/docs/search-by-post-category-in-wordpress/)- [Search by post tag](https://nexterwp.com/docs/search-by-post-tag-in-wordpress/)- [Search posts by title only](https://nexterwp.com/docs/search-posts-by-title-only-in-wordpress/)- [Add post listing in WordPress](https://nexterwp.com/docs/add-post-listing-in-wordpress/)

## Frequently Asked Questions

**Q: Why are pages still showing up in my WordPress post search results?**
A: That usually means the filter field has more than one post type selected. The search bar writes the chosen post type into the query before it runs, so if Page is included, the results widen again and pages can come back. For a posts-only search, keep only Post selected. That is the difference between a focused article finder and a broad site search.

**Q: Why is the dropdown not rendering in the search bar?**
A: The filter field needs both a source and at least one selection. If the source is set but nothing is chosen, nothing renders at all. That matters because the dropdown is built from the selected content types, not from the block alone. In practice, a missing selection looks like a broken block even though it is just incomplete configuration.

**Q: Why is an article missing from the search results?**
A: By default, only the title is matched. If the article’s title does not contain the search term, it will not appear unless content matching is turned on so the body text is searched too. That makes title-only search feel precise, but it also means long articles can be invisible when users remember a phrase from inside the post instead of the headline.

**Q: Does this search bar work if JavaScript is disabled?**
A: The block still submits as a real form because it renders a `` pointing at your site root. With JavaScript disabled, it degrades to WordPress’s own search results instead of breaking completely. That fallback matters on older browsers or restrictive setups, but you lose the richer dropdown behavior that comes from the block itself.

**Q: What do I need before adding a post-only search bar?**
A: Three things matter: Nexter Blocks Search Bar must be switched on under Nexter &gt; Blocks, published content has to exist for it to find, and you need to add a filter field with post type as its source and choose Post. Nexter Blocks Pro can be deactivated and the Search Bar still renders identically, so this works in Free edition too.

**Q: Should I leave Show All Result enabled for a posts search?**
A: Leaving it off is safer right now. On 5.0.6, Show All Result pre-loads three empty placeholders with no title, thumbnail, or link, and it ignores the result count you set. That makes the list look broken even when content exists. For a cleaner posts-only experience, let visitors search instead of preloading that view.
