Skip Navigation

[Resolved] Sorting post with the new Many To Many relationship

This support ticket is created 6 years, 9 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by Ying Zhang 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#682954

Tell us what you are trying to do?
Hi, our site uses the old intermediate type to create many to many relationships.
We have Artists, Artwork and Artshow CPTs
- An Artist can have many artworks
- Any of these artworks can be exhibited at various Art shows.

One of the issues we had with the old set up is that we can't sort via the intermediate types.
- eg, if I query "A list of the artwork by Van Gogh at 2018 Paris Art Show", I can get the list of the artworks, but I can't sort that list via the title or any of the attributes from the CPT "Artwork".

If we switch to the new many to many relationship, can we sort query results via one of CPT's property in that relationship? eg, "A list of the artwork by Van Gogh at 2018 Paris Art Show sorted by the date the artwork was painted."

Also, we currently use a pagination to display the returned query result.
eg "A list of the artwork by Van Gogh at 2018 Paris Art Show" will give me the correct list of artworks, what we'd like to do, is when the visitor clicks one of the artwork, they will go to the "Artwork view" AND be able to slide/ scroll tot he next and previous artworks from that query result. Pls let me know if such a scenario is possible to achieve.

What is the link to your site?
hidden link

Thank you!

#683417

Nigel
Supporter

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

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

Hi there

There are a few steps to arrive at what you are aiming for.

So, we are close to publishing release candidates for Types 3.0 and the related plugin updates concerning the new post relationship functionality.

A features cut-off was needed to be able to get to this point, and filtering and sorting by fields of related posts didn't make the cut.

Once the stable versions are published work will begin on some of the additional features, and this will be one of the priorities, but it won't be initially available.

Now, a migration wizard will help convert existing relationships into the new relationship format.

But the current implementation of many-to-many relationships is actually two one-to-many relationships, and that is what will be produced by any migration, i.e. two one-to-many relationships, albeit in the new format. Everything will continue to function much like before, but they won't be the same as starting out with a bona fide many-to-many relationship from scratch.

The above-mentioned filtering and ordering by fields of related posts would work for a many-to-many relationship, but probably not for two connected one-to-many relationships.

The developers are discussing adding an additional tool to convert two such one-to-many relationships into an actual many-to-many relationship.

As this would be a requirement for enabling filtering and ordering by fields of related posts on your existing project, I assume this is something you would like to see, and so I'm adding this thread to the internal ticket to represent your vote in favour.

Regarding the last point about pagination.

WordPress lets you add next and previous buttons to single posts, but they simply link to the next and previous chronological blog posts. There is no equivalent for custom queries with custom post types.

You could simulate it by creating a second View which is identical to the first but which has pagination settings that display only a single post at a time, and in the Loop Output section you would display the entire post rather than just a snapshot of content you may have included in the original View.

Then, in your first View instead of linking to the single posts you would link to a page with this second View which included all of the View URL parameters, including the pagination parameters that specify which individual post is currently being displayed.

I hope the above is all clear: it will be some time before what you want is possible, but it should be when the additional required features are added.

#722954

Hi Nigel,
Thank you for the detailed explanation.

What are the time frame for version 3 release? And that of the migration tool?

We were originally planning to do manual migration, but if the tool / new version will release in a reasonable time frame we might hold off and wait.

Secondly, The method you described to use a secondary view to achieve the prev/next style pagination, would that be achievable on our current version 2.2.9 or does it require the latest version at 2.2.23?

Thanks again!

#726153

Nigel
Supporter

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

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

The release candidates for Types 3.0 and related plugins will be published today or tomorrow, then 2-3 weeks will be required for QA testing before the final versions are published.

We will then be able to work on some of the additional features described above, but we will still be looking at some weeks of development time plus testing before such features are published, and that assumes everything goes smoothly.

I don't know how that fits in with your timetable.

Regarding the pagination, it is not dependent on the plugin version.

To create the correct links you would need to make that second View that displays just one post at a time and includes next/prev navigation links. Add that to a page and use the navigation links to move between the posts. Note the full URL in the address bar as you do so.

These are the URLs you would need to reproduce for your links in the first View. I haven't tried it to see what is required for the URLs or how to reproduce them, but I can't think of any other way to do this.

If you try that and run into problems could you please create a separate ticket for it. You are welcome to assign it to me.

#731356

Hi Nigel, thank you for the update!

I will follow your instruction and see if I can get the pagination working.

Cheers