Skip Navigation

[Resolved] sort records in a view by value in a taxonomy

This support ticket is created 2 years, 4 months ago. 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.

This topic contains 2 replies, has 2 voices.

Last updated by Steve 2 years, 4 months ago.

Author
Posts
#2508817

Hi this is for a museum that has multiple show in several galleries. The shows are in a post type (shows) and the name of the gallery is a taxonomy. At any given time there might be 3-5 galleries with shows in them and they want the page to display the shows in a specific order- I thought perhaps i could add a sort-order field to the taxonomy and display the whows sorted on that value-

Is that possible

Thanks

#2509529

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Steve

I'm not sure where you are outputting this, what the context for "they want the page" is.

But it sounds like you want to display Show posts, ordered by gallery taxonomy terms.

Within WordPress taxonomies are for grouping content, not for ordering.

You can order posts by post fields (standard post fields, or post meta fields): https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

So I don't think adding term meta to your gallery terms helps in this scenario.

You would need a solution where ordering was determined by fields of the show posts (e.g. a custom field).

Depending on what exactly you are trying to achieve, nested Views might be an option (in the legacy editor, they are not supported in the block editor). For example, you might have a taxonomy View that loops over the galleries, and in the output of that View another View which showed Shows belonging to each gallery.

#2509653

Nigel thanks yes a view in a view I think could work. I 'm using legacy views on this site- So i'll try that solution

Appreciate the help