Skip Navigation

[Resuelto] Sorting search results by post type

This support ticket is created hace 7 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 respuestas, has 2 mensajes.

Last updated by Tim Elliott hace 7 años, 2 meses.

Assisted by: Noman.

Autor
Mensajes
#488984

I am building a site in the educational field and have multiple post types. E.g. Posts, Pages, Courses, Speakers, People, Brochures, FAQs, Venues, Testimonials.

I am trying to create a global custom search where a single search box will bring back results from all of these post types. At preset a search on mutiple post types gives jumbled up results.

I would like the results to be grouped into their post type.

Therefore the results will look like:
<h2>Courses</h2>
Course 1
Course 2
Course 3
[AJAX Pagination if required]

<h2>Speakers</h2>
Speaker 1
Speaker 2
Speaker 3
[AJAX Pagination if required]

<h2>Brochures</h2>
Brochure 1
Brochure 2
Brochure 3
[AJAX Pagination if required]

etc., etc.

So to me this would work like a Taxonomy view, with sub views showing the contents of that taxonomy, but obviously with post type instead of taxonomy.

I can't see a way to do this other than to add a taxonomy that applies to all post types, and setting the values to the same as the post type - not a very elegant solution and it would rely on users always adding the correct taxonomy to every post - something users can't be relied upon to do.

Am I missing an easier way to do this?

Thanks
Tim

#489023

Noman
Supporter

Languages: Inglés (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Tim,

Thank you for getting in touch with us.

To display the result in groups for each post type using parametric search you should create separate views for your each CPT and set filters accordingly.

For example:

Posts:
[wpv-view name="posts view"]

Pages:
[wpv-view name="pages view"]

Courses:
[wpv-view name="courses view"]

Speakers:
[wpv-view name="speakers view"] and so on.

Relevant Documentation:
https://toolset.com/documentation/user-guides/#views-topics
https://toolset.com/documentation/views-shortcodes/#wpv-view

See this related ticket:
https://toolset.com/forums/topic/group-search-results-by-custom-post-type/#post-138709

Have a great day.
Thank you

#489170

Thanks for your help.

I

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.