I’m trying to design a **custom search page with separate sections for different post types (CPTs)** and I’ve already read [this]) and it didn’t provide the solution. Let me describe what I’m trying to achieve before adding some final important details.
Given: I have 2 CPTs — Episodes and Guests
Here is the workflow and the layout description for the search results page I’m intending:
1. Type a search term in the search field – let’s use “bull” and hit enter
2. Search results page loads
3. Guests that contain “bull” (case-insensitive) in their name (post title) appear at top sorted alphabetically ascending, limit 6
4. Episodes that contain “bull” (case-insensitive) in the post title appear at bottom in a separate section sorted by date descending, limit 8
**All matches for any post type should appear on the same page, sorted and organized as described.** The screenshot gives a visual of what I’m trying to achieve.
​
[Guests CPT results on top \(alphabetical\), Episode results on bottom \(sorted by date\)])I’ not even sure how to approach this. I’ve been researching and learning about different filtering plugins and search plugins and it seems that search and filter aren’t one thing like I thought they were. I really just want to get a good understanding of how to do this. Searching for “*custom search page*”, “*complex search page*”, and “*ultimate search results page*” ***don’t bring up anything that seems to apply here.*** The closest I get is stuff about WooCommerce, but this isn’t a shop and I’m not using WooCommerce.
Finally, I have a number of premium plugin suites with multiple widgets and I’ve no doubt the components to make my solution are probably in there, but again, **I’m unclear on how to create a results page sorted by CPT into a separate section for each CPT.**
Here are the premium plugins I have:
* Elementor Pro
* ACF Pro
* Crocoblock Jet
* Dynamic.ooo
* Essential Addons Pro
I prefer a plugin-based approach, but if there is a simple code solution I can drop in a code snippet, I’m open to that as well.
What approach would you recommend to achieve the desired results page?
[ad_2]