Skip Navigation

[Resolved] Sort custom posts by year

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

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

This topic contains 6 replies, has 3 voices.

Last updated by Waqar 1 year ago.

Assisted by: Waqar.

Author
Posts
#2667413

We do yearly summits, where speakers come and give talks.

I want to create a view that shows all speakers from previous years, shown in order by the most recent year they came and spoke. I also want to be able to show all talks from previous years. The main problem I'm having is the fact that some speakers have spoken multiple different years, and sometimes give the same talk, which seems to complicate ordering. I would like to have the ability to order and group by year. I'm not sure what the best long-term solution for this would be.

I had considered making a "years" taxonomy, with each year as an option, but I don't see anywhere to order posts by taxonomy. I imagine this is because taxonomy can contain multiple different values. Another option was to add a year option to custom fields, but I'm not sure what field type would work for that. Another option I had considered was to make each year a post type, and then just connect each speaker to the years that they spoke at.

I also considered having "year" be an intermediate custom field of a Speaker - Talk relationship. Or perhaps it would make most sense to create a Year -> Speaker -> Topic relationship? Ideally I would like to be able to sort topics or speakers by year.

Perhaps the simplest way to do this would be to combine these ideas? Use a custom date field for each speaker called "most recent year attended", and use that to order things, but then also use a taxonomy to be able to show posts in groups by year?

I would appreciate some guidance on which implementation would best match my desired use case, and be most future-proof.

#2667679

Nigel
Supporter

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

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

Hi there

I was reading through your description, but was promptly struck by a problem.

You have speakers and talks connected in a many-to-many relationship.

It's a limitation of Toolset m2m relationships that you cannot connect the same posts more than once.

So if "Nigel Anderson" gave a talk "Connecting related content" in 2020 he couldn't give that same talk again, Toolset doesn't allow such duplication.

So bearing that in mind this would need a more fundamental rethink.

It could entail duplicating the talk posts for each year, e.g. "Connecting related content in 2020", "Connecting related content in 2023", etc.

Is that an option?

#2668683

All our current data has just been put in elementor manually. That's part of the reason I want to move everything over to Toolset, so things can be automated and templated. I had only made the "speakers" and "talks" post types just to test different options. So any configuration is available at the moment.

That's part of the reason I wanted some input on what the best use case for this would be.

My description is more of me thinking aloud about how these relationships could possibly be set up. What do you think would be the best way to organize the data and post types, to achieve what I'm describing?

#2668775

Hi,

Thanks for writing back.

Based on what has been discussed so far, this is the structure that I'll recommend.

You can add a post type 'Talks' or 'Events', which will hold the posts that would represent each individual talk/event that is taking place.

For any data that you'd like to filter those talks/events by, you can add them as the taxonomy attached to that post type. For example:

- Speakers
- Years
etc.

For ordering the talk/event posts by date, you can add a date type custom field with this post type.

This combination should give you the best combination in terms of usability and performance.

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2669009

Thanks so much, that is very helpful! I'll work on creating that configuration.

#2669011

Wait, one clarification that I have.

How would I go about displaying speaker information using taxonomies? The speakers have pictures and bio information.

For example, if I wanted to list all the speakers for each year, how would I avoid duplicates of speakers, when they give multiple different talks each year?

#2669119

You're very welcome and glad we could help.

> How would I go about displaying speaker information using taxonomies? The speakers have pictures and bio information.

- Just as with posts, it is also possible to add custom fields to the taxonomy terms, from WP Admin -> Toolset -> Custom Fields -> Term Fields.

> For example, if I wanted to list all the speakers for each year, how would I avoid duplicates of speakers, when they give multiple different talks each year?

- The view for this will filter the events by a particular year taxonomy term. And in each event item, you can show information about the speaker term attached to it.

To avoid/hide the duplicates, you'll need some custom CSS or JS code workaround, depending on the overall structure of the view's output. You can start a new ticket once that view is ready and we'll be able to suggest the next steps, accordingly.