---
title: "How to Search Posts by Custom Field in WordPress?"
url: https://qa.nexterwp.com/docs/search-posts-by-custom-field-in-wordpress/
date: 2024-12-02
modified: 2026-04-14
author: "Aditya Sharma"
description: "Are you interested in searching posts using custom field data in WordPress? Custom fields let you add extra info to your posts, pages, products, or custom post types. Allowing users..."
image: https://qa.nexterwp.com/wp-content/uploads/2024/12/How-to-Search-Posts-by-Custom-Field-in-WordPress_-1024x519.jpg
word_count: 408
---

# How to Search Posts by Custom Field in WordPress?

## Key Takeaways

- Utilizes the Search Bar block from Nexter Blocks to search posts by custom field data in WordPress.
- Requires the Advanced Custom Fields (ACF) plugin to create custom fields like 'Location' for posts.
- Enables searching across various post types, including pages and products, by configuring ACF Filters in the Search Bar block.

Are you interested in searching posts using custom field data in WordPress? Custom fields let you add extra info to your posts, pages, products, or custom post types. Allowing users to search using this custom field data can significantly enhance the accuracy and relevance of search results.

With the Search Bar block from the Nexter Blocks, you can easily search any post type based on custom field data.

*To check the complete feature overview documentation of the Nexter Blocks Search Bar* block, [click here](https://qa.nexterwp.com/docs/add-a-search-bar-in-wordpress/).

***Requirement  - This block is a part of the Nexter Blocks, make sure it's installed & activated to enjoy all its powers.***

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

To do this, make sure you have created at least one custom field for any post type. You have to use the free[ Advanced Custom Fields (ACF)](https://wordpress.org/plugins/advanced-custom-fields/) to[ ](https://www.advancedcustomfields.com/resources/registering-a-custom-post-type/)create the custom field.

For instance, we’ll create a custom field called **location** for normal blog posts.

Then add the Search Bar block on the page or template and follow the steps -

### Create Custom Fields

Once you have the ACF plugin installed follow the steps - 

1. From the Dashboard, go to **ACF** > **Field Groups** and click on **Add New** button. 

2. Add a name to the field group.

3. Then add a field type and add a name. For instance, we’ll add a checkbox field with the name called Location.

4. Once done, from the **Settings** section set the location to Post under **Rules**.

![](https://qa.nexterwp.com/wp-content/uploads/2024/12/searchbar-custom-post-type-post.png)

5. Then click on the **Save Changes** button.

6. After that, you have to add value in the custom fields on some posts.

![](https://qa.nexterwp.com/wp-content/uploads/2024/12/searchbar-custom-post-type-post-editor.png)

### Use the Search Bar Block

Then add the Search Bar block on the page or template.

1. Open the item under **Search Bar** and select **Post** from the **Source** section.

2. From the **Select Post** dropdown, select **Posts**.

Now, you should be able to see a dropdown beside the search bar.

Then make the necessary changes to Label, Placeholder and Show Count sections.

3. After that, go to the **Standard Search** tab and click on the wrench icon of **ACF Filters**.

4. Then in the **ACF Key** field, you have to add the custom field name.

To find the field name in ACF, edit the field group there you will find the field name.

![](https://qa.nexterwp.com/wp-content/uploads/2024/12/searchbar-custom-post-type-post-location.png)

![](https://qa.nexterwp.com/wp-content/uploads/2024/12/searchbar-acf-filters.gif)

Now, you’ll be able to search posts by location names.

In a similar way, you can search pages, products, or custom post types by custom field data.