Skip Navigation

[Resolved] Query posts Type A in an A-to-B many-to-many, ordered by custom field of Type B

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 1 reply, has 2 voices.

Last updated by Waqar 1 year, 5 months ago.

Assisted by: Waqar.


Tell us what you are trying to do?

I have two post types that are used to associate one or more concert posters (i.e. "collectible") with one or more concerts (i.e. "event") via an intermedia post type ("event-collectibles").

The "event" post type has a custom field for "Event Date" ("wpcf-event-date") that stores a unix timestamp.

I would like to query the "collectible" post type to get all collectibles (posts_per_page = -1) sorted by most recent to least recent event date.

Is there any documentation that you are following?

Is there a similar example that we can see?

I only have examples using the old method using a custom query to join the _wpcf_belongs type fields.

I do not have an example using the new relationships tables.

What is the link to your site?

hidden link



Thank you for contacting us and I'd be happy to assist.

The filtering and ordering in query work with the custom fields that are directly attached to a post type. This means that if the custom field "Event Date" is attached to the post type "Events", then to order the results by this field, you'll need to set the view to show the "Events" post type and not the "Collectible" post type.

In the view's individual result or loop item, you can then show the related "Events" post(s), using a nested view with a post-relationship filter.
( guide on nested views: )

Note: The nesting of blocks-based views is not supported, so you'll have to create the child/nested view, using the classic/legacy views editor.

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


This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.