---
title: "How to Search Posts by Custom Field in WordPress?"
url: https://nexterwp.com/docs/search-posts-by-custom-field-in-wordpress/
date: 2024-12-02
modified: 2026-09-27
lang: en
author: "Aditya Sharma"
description: "Some of the most useful things about a post never appear in its title or body — a company name, a region, a model number, a speaker. Those live in..."
image: https://nexterwp.com/wp-content/uploads/2024/12/How-to-Search-Posts-by-Custom-Field-in-WordPress_-1024x519.jpg
word_count: 692
---

# How to Search Posts by Custom Field in WordPress?

## Key Takeaways

- Nexter Blocks Search Bar block searches any post type by custom field data, including posts, pages, products, and custom post types.
- ACF creates the custom field first by adding a field group, setting a field name such as Location, and assigning the location rule to Post.
- Search Bar block uses the Standard Search tab and the ACF Filters wrench icon, where the ACF Key field takes the custom field name to search posts by location names.

Some of the most useful things about a post never appear in its title or body — a company name, a region, a model number, a speaker. Those live in custom fields.

The Search Bar has a setting for matching an Advanced Custom Fields field. This page covers how it is set up and what it currently does.

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

> *Measured on Nexter Blocks 5.0.6 with ACF active: custom field search returns **no results for any term**. The cause has been identified and reported to the developers. Until it is fixed, do not build a search your visitors depend on around this setting. Everything below describes the setup so it is ready when the fix ships.*

## 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.- **Advanced Custom Fields installed and active.** The setting only does anything when ACF is present.- **A field with values saved on published posts.** An empty field has nothing to match.

## Steps

- Select your **Search Bar** block and open the custom field settings.

![Custom field settings](https://nexterwp.com/wp-content/uploads/2026/09/sb-acf-filters.webp)

- Enter the **field name** exactly as ACF has it.

![Entering the ACF field name](https://nexterwp.com/wp-content/uploads/2026/09/sb-acf-filters.webp)

- Decide whether matching should be partial or a full match.

![Match type settings](https://nexterwp.com/wp-content/uploads/2026/09/sb-acf-filters.webp)

- Publish, then search for a value you know is stored in that field.

![Searching a custom field](https://nexterwp.com/wp-content/uploads/2026/09/sb-fe-acf.webp)

## How It Behaves

What is intended, and what was measured, differ. Both are set out here so you can tell which you are looking at.

- **Measured result: zero, every time.** Tested with a real ACF text field carrying values on two published posts, across four terms and both match modes. Every search returned 0 results, with no error shown to the visitor.- **The cause is a database query fault**, not a configuration mistake. The query that collects candidate posts is escaped twice and is rejected before it runs, so the block ends up searching an empty set of posts. Full detail has gone to the development team.- **Intended behaviour**, from the same code path: the field value is split on the pipe character, and each part is compared against the term — partial match anywhere in the value, or full match against the whole value.- **The field name is ACF's field name**, the one shown in the field group editor, not its label and not its internal key.- **Custom field matching replaces the standard fields.** It is not added on top of title matching.

## Limitations

- **The feature does not currently return results.** Measured on 5.0.6. This is the limitation that matters; the rest apply once it works.- **ACF is required.** Without it the setting is ignored entirely.- **Only one field at a time.** There is no way to search across several custom fields.- **It is built for text fields.** Relationship, repeater and other structured field types do not produce a value this comparison can use.- **It will be slow on a large site.** The approach loads published posts and reads the field on each one per request, rather than querying the field directly. This has also been raised with the development team.

## Troubleshooting

### I set it up correctly and get no results

That is the known fault described above, not something you have done wrong. It affects every field and every term on 5.0.6.

### How do I confirm it is the known fault and not my setup?

Turn the custom field setting off and search for a word in a post title. If ordinary search works and only custom field search comes back empty, you are seeing the reported issue.

### What can I do in the meantime?

If the value also appears in the post title or body, search that instead with the standard field matching, which is measured working. It is not equivalent, but it is something.

### Which name do I enter?

ACF's field name, as shown in the field group editor. Not the label a visitor sees and not the internal key.

## Related Docs

- [Search posts by title only](https://nexterwp.com/docs/search-posts-by-title-only-in-wordpress/)- [Add a search bar in WordPress](https://nexterwp.com/docs/add-a-search-bar-in-wordpress/)- [Add a search bar for posts](https://nexterwp.com/docs/add-search-bar-for-posts-in-wordpress/)- [Search specific custom post types](https://nexterwp.com/docs/search-specific-custom-post-types-in-wordpress/)- [Advanced tab settings](https://nexterwp.com/docs/use-advanced-tab-in-nexter-blocks/)

## Frequently Asked Questions

**Q: Why do custom field searches return no results in WordPress right now?**
A: Nexter Blocks 5.0.6 has a known fault in the Search Bar’s custom field matching, so every term tested returned 0 results even when the field had values on published posts. The issue is not a setup mistake. The query that gathers candidate posts is escaped twice and fails before it runs, which leaves the search looking at an empty set of posts.

**Q: What do I need before searching posts by a custom field?**
A: The setup only works when Advanced Custom Fields is installed and active, the Search Bar block is enabled under Nexter &gt; Blocks, and the field has values saved on published posts. Nexter Blocks Pro was deactivated during testing, and the Search Bar still rendered identically, so Pro is not required for this block. Empty fields cannot match anything because there is no value to search against.

**Q: Which ACF field name should I enter for custom field search?**
A: Use ACF’s field name exactly as it appears in the field group editor. That matters because the Search Bar matches against the field name, not the label visitors see and not the internal key. If you enter the wrong identifier, you can end up testing a perfectly valid field while searching against nothing useful.

**Q: Does custom field search work with relationship or repeater fields?**
A: This setup is built for text fields. Relationship, repeater, and other structured ACF field types do not produce a value that this comparison can use. The intended behavior also splits values on the pipe character and compares each part against the term, so plain text fields are the practical fit here.

**Q: Can I search multiple custom fields at once in WordPress?**
A: The Search Bar only supports one custom field at a time. It does not search across several custom fields together, and custom field matching replaces standard fields instead of adding on top of title matching. That means this setting is narrow by design, so it is best used when one specific ACF field carries the data you want visitors to find.

**Q: What should I use while custom field search is broken?**
A: Use standard search against content that also appears in the post title or body, because that path was measured working. It is not equivalent to searching the custom field directly, but it gives visitors something usable until the fault is fixed. For broader setups, related options like [Search posts by title only](https://nexterwp.com/docs/search-posts-by-title-only-in-wordpress/) or [Add a search bar for posts](https://nexterwp.com/docs/add-search-bar-for-posts-in-wordpress/) may fit better.
