Skip Navigation

[Resolved] All Fields appear on the Ordering Options in a View even if the currently queried post type does not have such fields

This thread is resolved. Here is a description of the problem and solution.

Problem:
In a View when adding searches or orderby options we can choose from ALL fields we ever created on the site, but the View is only querying a specific post type with just one or some fields assigned and populated.

Will this be changing in future?

Solution:
No, but it changed in Toolset Blocks, which is another flavour of the Toolset Views Plugin. It uses a react native UX like WordPress Gutenberg and that is populated dynamically, so if using blocks you have only choices as available for the current queried or styled post.

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by Ben 6 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#1102607

Ben

I want to order a View by intermediary field, but when I do this the View returns 0 results.

I read in another support topic that this is possible if the intermediary post is set to public, which is the case for me, but nothing shows still.

#1103240

I do not think this should work, as filtering by fields of related posts as well is not possible yet, but I do see the Fields of Intermediary posts in the Order by settings of Views, and I do see the same error as you do when I try to build such a View.

Hence, I am sure this is not supported yet.
Can you please link me with the thread or article where this is elaborated, so I can check there why the information was provided and if there is eventually an internal issue tracker I can follow.

I am relatively sure that option is there by mistake and should not yet figure as an option but I may be wrong, in that case, it'd be a BUG.

In any case, I reported this and we will either fix or (as I suspect) introduce this in future.

#1103260

OK, I tested and confirm:
- You can order the posts that you currently query by their fields.
- You cannot query posts by fields of other posts that are not in the query or where that field is not added to
- But, unfortunately, you can still set them to order your output in Views, even if you query a Post Type that has no such field attached.

And that will always result in a "No results found"

So, if you want to Order posts you have to:
- Content Selection ==> The Post type where the field is assigned (and populated)
- Ordering ==> The Field of choice must be attached and populated in the queried Post Type

So, to order Posts by Fields of Intermediary Posts, you must query Intermediary Posts (and make sure those fields are populated)

The problem is sole that we provide the ordering by those fields even if you do not query the related post type, I reported that and we will fix it.

In a future release Toolset Views will allow to Query by Related Posts Fields and with that we will as well open the doors to Ordering by related fields

#1103266

Ben

Thanks for the help so far Beda.

These are the two threads I was referencing.

https://toolset.com/forums/topic/filter-and-or-sort-by-custom-field-in-m2m-relationship/
https://toolset.com/forums/topic/unable-to-use-intermediary-post-type-as-a-sort-by/

So to achieve what I want I understand that I must do the following.

Content Selection must be the intermediary post type that I want to order the view by a field of?

When I look to create a View, i cannot see any intermediary post types visible for selection.

#1103270

Ben

I managed to make intermediary post types available for content selection by visiting them in the Toolset dashboard and saving them.

This lets me order by the intermediary post type field, but i need to do this whilst displaying the data from another post type.

However, I think I may have found a way to accomplish what I need.

If I set up a View and set Content Selection to the intermediary post type. I can then order the View by the intermediary post type field.

Then I can edit the loop to display the fields of related data from the post type that i originally had in the Content Selection.