I have a view displaying Intermediary Posts.
hidden link
I can display fields from a relationship parent.
[wpv-post-featured-image item="@page-page-relationship.parent"]
<h2>[wpv-post-title item="@page-page-relationship.parent"]</h2>
[wpv-post-excerpt item="@page-page-relationship.parent"]
[types field='seating-capacity' format='FIELD_NAME: FIELD_VALUE' item='@page-page-relationship.parent'][/types]<br>
[types field='sort-order' format='FIELD_NAME: FIELD_VALUE'][/types]<br>
Note that sort-order is from the current post, not the parent.
The sort feature works using the sort-order field. However, it does not work using the post-title or seating-capacity (which are from the parent).
I suspect I need to modify this code to somehow reference the parent.
[wpv-sort-orderby type="radio" options="field-wpcf-sort-order,post_title,field-wpcf-seating-capacity" label_for_field-wpcf-sort-order="Field - Sort Order" label_for_post_title="Post title" label_for_field-wpcf-seating-capacity="Field - Seating Capacity" orderby_as_numeric_for="field-wpcf-sort-order,field-wpcf-seating-capacity" orderby_ascending_for="field-wpcf-sort-order,post_title,field-wpcf-seating-capacity"]
Since I can display post-title and seating-capacity, it seems like I should be able to sort by them. How can I make the sort work on this page?
Thanks
Lee
Dear Lee,
There isn't such a built-in feature within Views plugin, and it is a limiation of WordPress.
Views is using wordpress class WP_Query to query the posts, if you are going to sort the results by a custom field "Seating Capacity", all posts should have value in custom field "Seating Capacity", but in your case the custom field "Seating Capacity" is in another post type, so it conducts the problem:
No items found.
More help:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
'meta_value' - Note that a 'meta_key=keyname' must also be present in the query.
In my opinion: don't use parent post field to sort the result.
Thanks. I'll do things another way.