---
title: "How to Search Custom Post Types by Custom Taxonomy in WordPress?"
url: https://nexterwp.com/docs/search-custom-post-types-by-custom-taxonomy-in-wordpress/
date: 2024-12-02
modified: 2026-09-27
lang: en
author: "Aditya Sharma"
description: "Custom post types usually come with their own taxonomies — a docs type with a section taxonomy, a portfolio with a medium, a directory with a region. The Search Bar..."
image: https://nexterwp.com/wp-content/uploads/2024/12/How-to-Search-Custom-Post-Types-by-Custom-Taxonomy-in-WordPress_-1024x519.jpg
word_count: 507
---

# How to Search Custom Post Types by Custom Taxonomy in WordPress?

## Key Takeaways

- Nexter Blocks Search Bar block sets a custom taxonomy as the search source, so visitors filter custom post type content by taxonomy terms directly from the search bar.
- Advanced Custom Fields (ACF) creates a custom post type and custom taxonomy, and the example uses Books with Book Authors.
- AJAX Search updates results in real time without a full page reload, while All Result shows all matching posts on page load and Show Count displays the number of posts for each taxonomy term.

Custom post types usually come with their own taxonomies — a docs type with a section taxonomy, a portfolio with a medium, a directory with a region.

The Search Bar can put that taxonomy in a dropdown beside the input, and the block works out which post type the taxonomy belongs to on its own.

*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.- **A custom taxonomy registered against your custom post type**, with terms applied to published items.

## Steps

- Select your **Search Bar** block and add a **filter field** with **taxonomy** as its source.

![Adding a taxonomy filter field](https://nexterwp.com/wp-content/uploads/2026/09/sb-field-tax-cpttax.webp)

- Choose your custom taxonomy from the list, then publish.

![Choosing a custom taxonomy](https://nexterwp.com/wp-content/uploads/2026/09/sb-fe-cpttax.webp)

## How It Behaves

- **The post type is derived from the taxonomy.** Measured in the query builder: when a taxonomy filter is present, the block reads that taxonomy's registered object type and searches it, so you do not have to set the post type separately.- **Any registered taxonomy works the same way.** Measured across four of them — category, post tag, product category and product tag — all built their dropdowns from live terms.- **Choosing a term adds an exact taxonomy condition.** Measured: a single term returned exactly its 2 items out of 14.- **Terms with no items still appear**, because the list is not filtered by count.- **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.

## Limitations

- **A taxonomy attached to several post types resolves to the first one registered.** If your taxonomy is shared, the search will not cover all of them.- **Sub-term indenting only applies to the built-in category taxonomy.** Custom taxonomies render flat, however deeply nested they are.- **One term at a time.** The dropdown is a single choice.- **The taxonomy narrows, it does not search.** The typed term still has to match one of the enabled fields.

## Troubleshooting

### My taxonomy is not in the list

It has to be registered before the block can see it. Taxonomies registered late, or registered only in the admin, will not appear.

### The dropdown renders but choosing a term returns nothing

No published item carries that term, or the typed term does not match a searched field on the items that do.

### It is searching the wrong post type

The taxonomy is shared between post types and the block resolved to the first one. Use a post type filter field instead to be explicit.

## Related Docs

- [Add a search bar in WordPress](https://nexterwp.com/docs/add-a-search-bar-in-wordpress/)- [Search specific custom post types](https://nexterwp.com/docs/search-specific-custom-post-types-in-wordpress/)- [Limit search by a taxonomy term](https://nexterwp.com/docs/limit-wordpress-search-by-a-taxonomy-term/)- [Search by post category](https://nexterwp.com/docs/search-by-post-category-in-wordpress/)- [Advanced tab settings](https://nexterwp.com/docs/use-advanced-tab-in-nexter-blocks/)

## Frequently Asked Questions

**Q: What do I need before searching custom post types by a custom taxonomy in WordPress?**
A: The key requirement is a custom taxonomy registered against your custom post type, with terms already applied to published items. Nexter Blocks, part of Nexter, Nexter WP, NexterWP, nexterwp.com, Nexter Theme, Nexter Blocks, Nexter Extension, Nexter Suite, POSIMYTH Nexter, also needs the Search Bar block switched on under Nexter &gt; Blocks in your WordPress dashboard. That setup matters because the dropdown is built from live terms, not from a manual list.

**Q: Can the Search Bar figure out which post type belongs to a taxonomy automatically?**
A: The Search Bar reads the taxonomy’s registered object type and searches that post type on its own. That means you do not have to set the post type separately when a taxonomy filter is present. In practice, this is useful when a docs section taxonomy, portfolio medium, or directory region already points to one content type and you want the filter to stay tied to that relationship.

**Q: Why does choosing a taxonomy term sometimes return no results?**
A: Two common reasons are listed: no published item carries that term, or the typed term does not match one of the searched fields on items that do have it. The block narrows results by an exact taxonomy condition, but it still depends on the item matching the enabled search fields. That distinction matters because the dropdown filters content first and search text still has to line up with what is being searched.

**Q: Does this work with shared taxonomies across multiple post types?**
A: Shared taxonomies are where this gets tricky. If a taxonomy is attached to several post types, the search resolves to the first one registered, so it will not cover all of them. That is why a shared taxonomy can appear to point at the wrong content set. When you need explicit control, use a post type filter field instead of relying on the taxonomy alone.

**Q: What are the main limitations of searching by taxonomy in this setup?**
A: The dropdown is single-choice only, so one term at a time is all you get. Custom taxonomies also render flat, even if they are deeply nested; only the built-in category taxonomy gets sub-term indenting. Another important limitation is that the taxonomy narrows results rather than searching by itself, so the typed term still has to match one of the enabled fields.

**Q: Why does the search bar still work without JavaScript?**
A: It degrades to an ordinary search because the block renders a real  pointing at your site root. With JavaScript disabled, it still submits and lands on WordPress’s own search results. That fallback matters if you care about basic resilience: even when enhanced behavior is unavailable, users still get a working search flow instead of a dead control.
