Hi, I know this as been already discuted, but there is a missing field in the filter of my view.
I can't see "Select items [...] as related items of..."
Any help would be appreciate.
Thx
Hello, did you choose a post relationship Query filter, or a post parent Query filter? The post parent filter is something different, and doesn't apply to post relationships. It is used for hierarchical post types, like Pages, where one Page can be a child of another Page.
- Can you take a screenshot of the post relationships Query Filter from your site and include it in your next reply?
- What versions of Types and Views are you using? Please provide your site's debug information as described here: https://toolset.com/faq/provide-debug-information-faster-support/
- If you go to Toolset > Relationships, what do you see? Please provide a screenshot.
I'll review your responses and give you some feedback.
Thank you for your quick response, I'm using Types 3.3.10 and View 3.1.3, WP 5.4
I want posts to be filtered by a Cutom field:
New-York
...Kennedy school
...Gabdhi school
Boston
...Stalin school
...Castro school
- If you go to Toolset > Relationships, what do you see? Please provide a screenshot.
It says “old storage", maybe it's because of this? This site wasn't developped by me.
It says “old storage", maybe it's because of this?
Yes, if the site has not been migrated to the new relationships system, the post relationships filter will not show the "Select...as related items of" field because it's not necessary. The only type of post relationship is a parent / child relationship, so the only post relationship filter possible is a filter to show children of some specific post. There are no many-to-many relationships or RFGs.
I want posts to be filtered by a Cutom field:
Okay if you only want to filter by a custom field, you don't need a post relationship filter...you need a custom field filter. Maybe you can explain a bit more about what you want to accomplish, and I can offer some more feedback?
What type of custom field is it? Which post type has the custom field? Why do you think you need a post relationship filter?
I'll try to do my best to explain what I am trying to accomplish.
I have custom post types “schools“
schools has custom fields, such as “how many children“ and “city“
I want to show the schools belonged to each city
city A
-school 1
-school 2
city B
-school 3
-school 4
-school 5
Hope I'm clear.
Regards
Okay thank you for the information, I understand a bit more now. It sounds like "city" is a custom field in the School custom post type. There is no custom post type "City". To use a post relationship filter, you must have at least two custom post types - School and City. That is not how your site is set up, so you must not use a post relationship filter here. You must use a custom field filter instead. I would start over with a new View of Schools, and add the city field custom filter. I would also use the Ordering panel to order by the city custom field value as the primary order, and then choose the secondary order based on the School post title or something else. I can give you more step-by-step information if you tell me whether you are using the classic View editor or the Blocks editor.
Haw yeah, you rules!
I have a last enquiry about that: I want a city displaying all scholls related to. Actually it displays each one at the time, see attached picture.
I use classic view editor
No, unfortunately you could do this with post relationships but not with custom fields. There is not an easy way to group custom field values like this in a View.
OK, is there a way to display it with shortcode?
Something like : [wpv-view name="schools" wpv-city="new-york"]
This way I could put many views on the page, one per city
Yes, you can set up a custom field Query Filter to respond to a shortcode attribute. Edit the View and find the Query Filter section. If you cannot find it, scroll to the top right corner and click "Screen Options". You can activate the Query Filter here. Then add a new Query Filter based on the city custom field. In the configurations you can set it to respond to a shortcode attribute. Then use the shortcode attribute to filter by different custom field values. This is called passing arguments to Views, and is described here: https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/
That works perfectly!
I'm thinking of a way to automate my goal (display city name only one time, watever the amount of schools):
A view like that:
[types field='name-of-the-city'][/types][wpv-view name="ecoles" city="code-that-displays-'name-of-the-city'"]
Maybe it's too weird, if so don't bother.
Many thx for all, truly appreciated!
Well you would have to create a custom post type for Cities in order to loop over them with a View. Views cannot loop over the values of a custom field. It can only loop over posts of some kind, Users, or terms in a taxonomy. So the simplest solution is to write out the city names manually, then write the shortcode attribute manually for each city.
My issue is resolved now. Thank you!