Show Custom Post Types and Pages in the search results on the TwentyTwenty Theme

Im looking to show more data in the search results.

Including; Pages, CPT, ACF etc.


Hi @mike

Welcome to the Frontity community. Good to see that you’re trying out Frontity.

At the moment the wp-source package only returns search results for posts, as you need to send separate queries for posts, for pages, for each CPT, etc…

However, there is a possible solution. You will need to be using a self-hosted site, rather than a site as your API, as you need to be able to install a plugin.

This plugin will add a multiple-post-type to the WordPress REST-API that will enable you to search multiple post-types.

You will, however, need to write your own handler to fetch the results and process them. See our docs on the wp-source package. As part of the params passed to api.get you should add a types array with the posttypes you want to fetch, something like:

types: ['posts', 'pages', 'my-cpt']

Hope this helps.


I’m also interested in searching in a CPT, I installed the plugin but I don’t understand on the frontity side how to configure the search.

Do you have an example to propose?


3 posts were split to a new topic: Universal search which searches for all the Posts and CPT

Hi @d1cg018, Welcome to the Community!

Here you have additional info on this topic:

In the twentytwenty theme there’s an implementation of a search feature using WordPress engine (search links as ?s=anyKeyWord)

Here you have the React components used for that

Taking this into account, if you want to trigger an alternative search when your users go to these search links (?s=anyKeyWord or any other you may want to use), you can create a custom handler to perform alternative searches

Here you have an example from a member of the community that implemented her own search results link with a custom search

libraries.source.handlers is a powerful resource in Frontity projects as they allow to define custom links that can be fetched with actions.source.fetch()

Hope this helps