Skip Navigation

[Resolved] Ordering posts in a relationship with another post

This support ticket is created 5 years, 1 month 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1362943

Hi there,

I have two custom post types: Contributors and Resources. They are in a many-to-many relationship. When I connect multiple Contributors to a given Resource, is there a way that I can ensure the order of the Contributors? To be less abstract, let's say I have an article that's been written by two people, Jane Brown and John Smith. Jane is the primary author and John is the secondary author, and I need to ensure that Jane's name precedes John's. Does that make sense?

Thank you!

Saul

#1363105

Dear Saul,

Yes, it is possible to customize the order of related posts.

For example, you can try these:
1) Create a many-to-many relationship between post types Contributors and Resources,
- in step "Relationship fields", add a custom numeric field "sort-order".
- in step "Names", enable option "Intermediary Post Type visible in WordPress admin menu".
in section "Intermediary Post Type and Custom Fields", add a custom numeric field "sort-order".

2) Edit each "Resources" post, related with some "Contributors" posts, setup the "sort-order" field values
3) In single "Resources" post, setup a post view:
- Query the posts of post type "Resources Contributors Intermediary Posts",
- Order the result by field "sort-order"
- Filter by the post type relationship:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
- In view's loop, display it's related Contributors information
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent