Show custom post types in search results, tags, categories, etc

Hello everyone!

I am yet very new with Frontity and on this platform.
However, I thought I share some ideas I’ve got recently by exploring Frontity and its amazing features.

Since I was looking for the answer for myself in the first place and I’ve not seen this in this forum (I may be wrong, please correct me if I am), I thought it might be beneficial for other users to share my ideas.

First of all, thanks to the amazing Frontity developers who have made it possible to use react.js together with popular WordPress CMS.

I’ve tried a long time to develop something like a post feed, combined with multiple post types on one page. For instance, develop the recent posts from all post types (post, page, custom post type, etc.).
I came up with the solution, using the state.source.params from @frontity/wp-source API Reference and reading the article on How To Query Multiple Post Types With One Request To The WordPress REST API.. Together with this, I’ve managed to add my custom post types in one API endpoint to show them on the archive page.

By default, WordPress does not add custom post types to the default API endpoint. That results from Frontity not display them in default archive or, i.e., search results or default tags/category page (since Frontity is relying on WP API to retrieve the posts). However, doing little coding can easily solve this problem.

If you are not familiar with the coding in WP, you may want to install a plugin called REST API Multiple Post Types. This plugin does the trick automatically. However, please note, as you see, this plugin has not been updated for a while. I have not tested its vulnerability, so please install it only at your own risk or manually edit the code!

For instance, let’s say you have custom post types like “videos” or “galleries”. Doing little coding (or installing the plugin) on the WordPress side and using the Frontity state.source.params documentation, you can easily define your custom post types in (for example):

          params: {
            type: ["post", "videos", , "galleries"],

That would be in “GET” request something like /wp-json/wp/v2/posts?type=videos&type=galleries, which fetches not only posts but also all those custom post types defined in your frontity.settings.js. I found it a great solution if you want to query all your posts (including those coming from custom post types) in search results. In other words, to show all your posts that are registered in API.

(oh, and this is elementary when it comes to the custom post types - make sure they are registered and available in WP API registry)