Do you want to include custom post types in WordPress search?
By default, WordPress will never show custom post types in its search results. That means your visitors may miss out on some great content, and you’ll miss out on extra page views.
In this article, we will show you how to include custom post types in WordPress search.
The easiest way to include custom post types in WordPress search is by using the SearchWP plugin.
Upon activation, click on the new ‘SearchWP’ button in your website’s toolbar. You can then go ahead and click on ‘Activate License.’
After you’ve done that, click on the ‘License’ tab.
Once you’ve pasted this information into the ‘License’ field, go ahead and click on the ‘Activate’ button next to it.
You can now set up SearchWP to include custom post types in WordPress search results.
To start, simply click on the ‘Engines’ tab.
To include custom post types in your searches, click on the ‘Sources & Settings’ button.
Under ‘Sources,’ you’ll see all your post types listed along with comments, media, and more. Simply find all of the custom post types that you want to include in your search results, and check their boxes.
After that, click on the ‘Done’ button.
In each section, SearchWP shows all the attributes that it will look at when searching your custom post types.
For each attribute, SearchWP has an ‘Applicable Attribute Relevance’ scale. This is the weight that SearchWP gives to this attribute when searching your custom post types.
By default, the sliders for Title, Slug, and Excerpt are all the way to the right, so they have the most weight. The slider for Content is in the center, so it has less weight.
Want to change an attribute’s weight? Simply drag its slider.
You may want to try different relevancy settings to see what gives you the most accurate and helpful search results.
You can also remove attributes. For example, your custom post type may have attributes that you want SearchWP to ignore, like attributes that you added for your internal reference only.
To add or remove attributes, click on the ‘Add/Remove Attributes’ button.
To add an attribute, simply click to check its box.
If you want SearchWP to ignore an attribute, then go ahead and uncheck its box.
To do this, simply click on either the ‘Custom Fields’ or ‘Taxonomies’ fields. You can then type in the name of the attribute that you want to add, and click on it when it appears.
When you’re happy with your settings, click on the ‘Done’ button.
If you’ve added any attributes, custom fields or taxonomies, then you can change how much weight this content has. Just like we mentioned earlier, moving the slider to the right will give this attribute more weight which means it will have a bigger impact on the search results.
Once you’ve finished customizing SearchWP’s settings, scroll to the top of the screen.
You can then click on the ‘Save Engines’ button to save your changes.
At this point, SearchWP may show you the message ‘The index needs to be rebuilt.’
If you see this message, then go ahead and click on the ‘Rebuild Index’ button. This will add your custom post types to your site’s search index, so they will show up in the search results.
That’s it. WordPress will now include your custom post types in its search results.
Once you’ve done that, you may want to enable some advanced settings that will make it easier for visitors to find what they are looking for.
To take a look at these settings, click on the ‘Advanced’ tab.
This screen lists some of the more advanced settings that you may want to use.
For example, if you want to show results that don’t quite match the term that the visitor searched for, then you can check the ‘Partial matches (fuzzy when necessary)’ box.