Skip Navigation

[Resolved] Sorting order of relationship post type items

This support ticket is created 6 years, 2 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
- 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 22 replies, has 5 voices.

Last updated by Minesh 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1100325

Jim

I have two custom post types with many to many relation: articles and authors

Now I can to add authors to an article and that works great but I want to be able to set the order of the authors (because the order determines the contribution importance from that author for the article).

I can now add authors like this:
hidden link

but it would be great if I can drag and drop the authors in the right order.
Is that possible?

#1100581

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - there is no such feature available to order the posts within the post-relationship box. If you agree I will take this request as a new feature request and pass it to the concerned department for assessment.

Please note that there is no ETA on it.

#1100593

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Passing this ticket to a colleague who handles the Feature Request.

#1101427

Jim

Thnx Minesh,
Is there any other way to set the order of the authors on the article page?
I have got to print them in the right order here...

#1101544

The idea is great, but there are no (current) features that can help you to either drag and drop or control the order of those posts in the related posts table.

It is possible however in Repeatable Field Groups.
Maybe you can work with those?
There, you can also "because the order determines the contribution importance from that author for the article" (because, you will be able to display those fields by their order in the post, something, that you cannot do with post types!)

I can request the feature to be able to visually re-order those posts, and access their order in the list.
However, this is not a priority and will take a lot of time, because we as well have pagination there, which will disrupt drag and drop or ordering totally.

Please let me know if RFG's (Repeatable Field Groups) are not valuable for this:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/

In that case, I can add the request, but this will take a longer time (DEV) and needs more users supporting the idea, I think.

#1102424

Jim

Thanks Beda for your suggestion.
Is it possible to use repeatable fields groups with a custom post type?
So I will create a repeatable field groep for the article, and instead of adding fields to this group, I want to be able to select the authors(s).

If this won't work then there must be some other solution to this problem. I cannot believe this is a feature that only I need; being able to set the child post types in a certain order...

#1103237

Is it possible to use repeatable fields groups with a custom post type?

Repeatable Fields Groups can only be used for Post Types, and only for one post type a time.
(It cannot be assigned to many post types).

Hence yes, they can (and should) be used on a Post Type.

So I will create a repeatable field groep for the article, and instead of adding fields to this group, I want to be able to select the authors(s).

You would:
- create a Post Type (Article)
- Create a Repeatable Field Group (RFG) for that Post Type
- In that RFG, you will add Fields. For example a Single Line, or Select Field
- When you add Posts you add RFG's to the posts as well, and within them populate your fields (authors, for example)

It is a bit tricky if you want to have those fields be "prepopulated" with authors, that is not possible out of the box.
But since you create your Author Posts anyway manually as well (I suppose) you could actually just populate a Select Field with all the required author names for example.
That is done once and can be reused.

When you then populate many times the Select (Author) field for the RFG that is added to the Article, you can later display those Authors when you view the Article.

The very, very simplest approach for this is actually a Repeating Field (This is different than a Repeatable Field Group), where you simply add a repeating single line to the Articles posts, so you can add as many authors you want each article

It depends a lot on what data you need to save against the authors, so to choose what to use.
If you need only their name, a repeating single line is enough.
For more complex information a Repeatable Field Group with an Author Select Field and additional fields for the author data can do
For a fully customizable data set a Post Type would be needed, whereas we are back the request to drag and drop those into an order, which is not possible.

I filed this request here:
https://toolset.com/feature-request/allow-to-drag-and-drop-related-posts-into-custom-order/

You can upvote it here (please do so, as otherwise, it will not gain traction):
https://toolset.com/feature-request/?wpv_post_search=Allow+to+drag+and+drop+related+Posts+into+custom+order&wpv_view_count=686737

If above workarounds won't help, the request is filed and eventually we can look into this.

#1104346

Jim

Hi Beda,
really appreciate your help here.
I am affraid your solutions are not working for me at the moment...

I noticed in the database the table "wp_toolset_associations", is that still in use or not?

I was thinking maybe if something like tjhis exists ( a linking table) I could add a timestamp field to it and then order by that timestamp field Acending. So then the related posts can be ordered in order to which they are added to the parent.

That could work. What do you think?

#1104417

Jim

Looking at this example here: https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

The example talks about Album(s) (parent) and Songs (Child) and a third field: Track; the location in thealbum where the song appears!
Isn't his exactly what I need? -> Album = Article, Song = Author and the Track = the Order (weight/sorting of the author on the article).

Unfortunately is the explanation of this example and how to build it not included on that page...

Can you tell me if this is correct and would this solve the problem??

NB: one more this to note is that my website is a little more complex because the article is also a child (from the Journal post type). So the complete chain is like this:

Journal - article - author

Journal - article = one to many relationship
The article to author is a many to many relationship

#1105311

I noticed in the database the table "wp_toolset_associations", is that still in use or not?

Yes, this is where Types stores the new kind of Post Relationships.

I was thinking maybe if something like tjhis exists ( a linking table) I could add a timestamp field to it and then order by that timestamp field Acending. So then the related posts can be ordered in order to which they are added to the parent.

Well, but that requires a total change in the database, we cannot support this.
I can file the request to be able to sort by some data the related posts table.
https://toolset.com/forums/topic/sorting-order-of-relationship-post-type-items/#post-1101544

Related to this.
https://toolset.com/forums/topic/sorting-order-of-relationship-post-type-items/#post-1104417

That is about Front End display of things, of course there you can order the posts appearing, in Toolset Views, there is an option for ordering and sorting.
You can, for example, order posts by their ID, name, title, date, even Custom Fields.
But that is all about the front end output, not the backend.
But this is not what I understand you require as the request is about having a method to order the related posts in the backend, and that is not possible.

I can add the request, I see no solution currently but to use RFG's instead of Post Types (which may not be a good solution in your case).

I can however not grant an ETA, this is out of my hands unfortunately.

#1105317

Jim

Hi Beda,
I am not sure if you understand my needs for this topic...

What I need is to be able to display the authors (Child post type) on an article (parent post type) in order of importance. So I do mean the front-end.

Just like the example of the Album and songs: the songs must be displayed in a particular order on an album.
On another album the songs may apear in a different order so the order must be set on the album level.

For this to happen I must be able to set the order in the backend ofcopurse. And I do not mind how, it does not have to be by drag and drop. I just need a way to set the order of the children for that article so that in the front I see them in the right order.

Does that make sense?

#1106356

I understand now.

The request forwarded to me was about ordering in the backend, but I see now what you need.

This can be done in the Toolset.
Minesh can explain to you how, and for this purpose, I re-assign the ticket to him.

In Short:
- Create your Relationship as you intended to
- To the "Intermediary Post Type" (This is visible when you edit the Relationship in Toolset > Relationships) add a (for example) numeric Field or similar where you can store (for example) a numeric value, representing the "Order" or "Importance" of the author in the article.
- Then, when you create new connections of Authors to Articles, each connection creates an Intermediary Post (the connection)
That one is unique for each connection.
- So now you can set an order in the field you added, and later query the Intermediary Post Type in a View.
- In that View you set a Query filter to get the related Intermediary posts to the current post where the view is displayed (which will be an article), and in the Loop, you return the related Authors data and display it.
- Set an ordering rule by the field you created for the intermediary post type

This will now output a list of authors on an article ordered by the unique importance of the Author/Article connection.

#1106370

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please try to follow the steps shared by Beda in the previous reply and try to resolve your issue.

#1106523

Jim

Ah! finally we are getting there. I have regained hope this is gonna work 🙂

I have added the intermediary post type and changed the view to be sorted by this intermediary post type, but now I get no results anymore...

When I remove the sorting the results are there but with it doesn't work...
Have a look: hidden link

I have set the intermediary post type field as a "select" field. With numbers 1 to 20
This way we can easily set the order.

Please let me know what I am doing wrong...
Hope to hear from you soon.
Thnx, Jim

#1106525

Jim

Oh, and here is a screenshot from the linked authors of an article:

hidden link