Navigation überspringen

[Geschlossen] Is it possible to "orderby" relationship when using in a WP_Query?

This support ticket is created vor 10 Monaten, 3 Wochen. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Dieses Thema enthält 3 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von Minesh vor 10 Monaten, 2 Wochen.

Assistiert von: Minesh.

Author
Artikel
#2702890

Tell us what you are trying to do?

I was able to "filter" a query by including the toolset_relationship parameter in a WP_Query based on this documentation: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#wp_query-argument-for-querying-by-related-posts

It worked great! But I wonder if it's possible to "orderby" the relation children post title.

Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#wp_query-argument-for-querying-by-related-posts

Thanks in advanced for your help!

#2703087

Nigel
Unterstützer

Sprachen: Englisch (English ) Spanisch (Español )

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

Hi there

I'm not quite sure I follow what you want to do.

The documentation you linked to describes modifying a query so that you filter by a Toolset relationship, e.g. (from the documentation) query books but only return books that are linked to a specified writer post.

We will get back possibly multiple book posts, connected to one writer.

What order do we want to specify?

It is trivial to order by the title of the returned book posts by setting the orderby attribute to 'title'.

You must mean something else, I'm guessing.

#2704408

Hi, thanks for the response.

Let's take that example (one writer with multiple books). As you mentioned, I can use "orderby" = "post_title" to sort all books alphabetically.

But what if I want to order the results, in the same order that the books were connected to the writer?

That's what I'm trying to achieve. Something similar to "orderby" = "relationship_order". Is there a keyword for that?

#2704585

Minesh
Unterstützer

Sprachen: Englisch (English )

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

Here is a sandbox site and you can auto-login to it using the following link:
- versteckter Link

Can you please setup your post type with post-relationship or you can use existing one and tell me with one example parent and child post what with that keeping in mind what would be your expected results?

Das Thema „[Geschlossen] Is it possible to "orderby" relationship when using in a WP_Query?“ ist für neue Antworten geschlossen.