Do you want to make custom fields searchable in WordPress?
By default, WordPress doesn’t include custom fields in its search results. If you use custom fields on your site, then including them in your search results can help visitors find what they’re looking for.
In this article, we will show you how to make custom fields searchable in WordPress.
What Are Custom Fields & Why Make Them Searchable?
WordPress automatically adds metadata such as the title, author, date, and time to your content. However, you can store additional information about a page or post using custom meta boxes.
If you are using WooCommerce, then some of your custom product attributes may also be classed as custom fields.
The problem is that the default WordPress search ignores these custom fields and only looks for matches in the title and content. By making your custom fields searchable, you can help visitors find pages, posts, products, and other important content.
That said, let’s look at how you can make custom fields searchable in WordPress.
Making Custom Field Searchable in WordPresss
The easiest way to make custom fields searchable is by using the SearchWP plugin. It’s the best WordPress search plugin and allows you to show more helpful and relevant search results by creating a custom search algorithm.
With SearchWP, you can search content that WordPress ignores by default, including custom post types, PDF files, WooCommerce products, categories, and custom fields. This allows you to improve the WordPress search for your users.
The first thing you need to do is install and activate the plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, go to SearchWP » Settings and then click on the ‘General’ tab.
Here, you need to enter your license in the ‘License Key’ box. You can find this information in your account on the SearchWP site. Once you are done, make sure to click the ‘Verify Key’ button.
Create a Custom Search Algorithm
After activating the plugin, you can fine-tune how SearchWP indexes, searches, and displays your content. You can think of this as creating a custom Google search algorithm that’s just for your WordPress blog or website.
To start, head over to SearchWP » Algorithm.
Here, you’ll see a section for the different content types that SearchWP searches by default, such as pages, posts, and media files.
To get started, simply scroll to the content where you want to start searching custom fields. In our images, we’re searching the custom fields attached to Posts, but the steps will be exactly the same for all content types.
In your chosen section, find the ‘Add/Remove Attributes’ button and give it a click.
In the popup that appears, click to open the ‘Custom Fields’ dropdown menu.
To search all the custom fields, simply select ‘Any Meta Key.’
If you want to search specific custom fields only, then start typing their names and then select the right option when it appears. Once you’ve chosen the custom fields that SearchWP should include, click on ‘Done.’
After that, you’ll see a new ‘Custom Fields’ option in this section.
Each custom field has its own Application Attribute Relevance slider, which allows you to control how SearchWP ranks the content on your online marketplace, blog, or website.
For example, if you move a slider to the right, then the custom field will carry more weight. This means it’ll have a bigger impact on where the content appears in the search results.
When you are happy with how the search algorithm is set up, scroll to the top of the screen and click the ‘Save’ button.
SearchWP will now rebuild the index automatically.
Depending on the speed of your Internet connection and your WordPress hosting provider, this may take a few minutes.
As soon as you see ‘Index Status 100%,’ you’ll know that SearchWP has indexed your PDF metadata, custom fields metadata, images, files, and any other types of metadata that you’ve chosen to include in your website’s search.
WordPress will now start showing relevant custom fields on its search results page.
How to Improve WordPress Search with SearchWP
This is a great start, but there are more ways to improve the built-in WordPress search with SearchWP. This will make it even easier for visitors to find what they’re looking for.
To do that, go to SearchWP » Settings and scroll to the ‘General Settings’ section.
Here, you can activate any of the following settings:
- Partial matches. With this setting enabled, SearchWP will display results that aren’t an exact match for the visitor’s search query.
- Closest match. After enabling partial matches, you can also show the closest matches when a search has no results.
- “Quoted” searches. This allows visitors to search for exact phrases using quotes.
- Highlight terms. Automatically highlights the search terms to help visitors find what they’re looking for.
To help you fine-tune your website’s search, it’s a good idea to monitor how visitors are using the search feature. This allows you to see what’s working and what’s not working on your WordPress blog, so you can constantly improve your site’s search and help visitors find what they are looking for.
To see the search history and most popular search terms, simply select ‘Statistics’ in the left-hand menu.
SearchWP will show detailed information from the past 30 days, the last year, or the entire history of your site. This data can even help you generate blog post ideas by showing the topics that visitors are most interested in.
We hope this article helped you learn how to make custom fields searchable in WordPress. You may also want to look at our guide on custom fields 101 and our expert picks for the best WordPress SEO plugins and tools.