---
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-27
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: 591
---

# How to Add Search Bar for Posts in WordPress?

## Key Takeaways

- Nexter Blocks Search Bar restricts results to posts by switching on Only for specific CPT and setting CPT Type to Posts in the WordPress dashboard.
- Search Bar matches only the title by default, and a term returns 4 posts when restricted to Posts versus 15 results across all types when unrestricted.
- Search Bar renders a real at the site root, so with JavaScript disabled it still submits to WordPress’s own search results.
- Search Bar shows only published posts, and drafts or private posts never appear in the results.

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, open **Extra Option**, and switch on **Only for specific CPT**.

![The Search Bar block](https://nexterwp.com/wp-content/uploads/2026/09/sb-cpt-posts.webp)

- Set **CPT Type** to **Posts**.

![Choosing post as the searched type](https://nexterwp.com/wp-content/uploads/2026/09/sb-cpt-posts.webp)

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

![Searching posts only](https://nexterwp.com/wp-content/uploads/2026/09/sb-fe-posts.webp)

> *There is also a per-field **post type** source in Search Bar Fields, with a Post/Taxonomy toggle, that looks like it does the same job. Measured on 5.0.6: choosing Post there saves with no post type attached and has no effect on the search — no dropdown renders on the front end and nothing is restricted. **Only for specific CPT**, used above, is the setting that actually works. Reported to the developers.*

## How It Behaves

- **The post type is written into the query before it runs.** Measured with **Only for specific CPT** set to Posts: a term returned 4 results; the same term unrestricted returned 15 across all types.- **It is one type at a time.** Measured: the setting takes a single CPT Type value — Posts, Pages, Products or any registered custom post type — not a combination.- **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.- **It restricts the whole search bar, not one field among several.** There is currently no working way to offer a visitor a choice of post types in one instance — see the note above.- **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

Check that **Only for specific CPT** is switched on and **CPT Type** is set to Posts, not left on its default.

### I added a filter field instead and it is not restricting anything

Expected on 5.0.6 — the per-field post type source does not work (see the note above). Use **Only for specific CPT** instead.

### 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/)