How to Search Specific Custom Post Types in WordPress?

Table of Contents

Custom post types allow users to organize and display their content in a more structured manner. However, as the amount of content on a website grows, finding specific custom post types can become a challenging task. This is where allowing users to search by specific custom post type can be helpful.

With the Search Bar block from the Nexter Blocks, you can easily search posts from custom post types in WordPress.

To check the complete feature overview documentation of the Nexter Blocks Navigation Menu block, click here.

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

To do this, make sure you have created at least one custom post type, you can use the free Advanced Custom Fields (ACF) to create a custom post type.

For instance, we have created a custom post type called Books.

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

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

2. From the Select Post dropdown, select your custom post type i.e. Books here.

searchbar post books

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

In the Label field, you can add a label name for the select dropdown.

In the Placeholder field, you can add a placeholder text for the select dropdown. 

From the Show Count toggle, you can show the number of posts the item has in numbers.

3. Now go to Extra Option tab and enable the AJAX Search toggle.

searchbar ajax search 3

Now you can select your custom post types from the dropdown to show all the posts in the search result or you can directly search for the custom post type.

Still in Doubt? Let’s Assist You

Need Help? Ask AI Bot

Have Feedback or Questions?

Join our WordPress Community on Facebook!

Related Docs