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.

Cheers

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 wordpress.org site, rather than a wordpress.com 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.