Hello,
Using Toolset I created a parent "Sector" which contains a number of "Routes"
Each "Route" has a custom field "Difficulty Grade", which I can assign via a Select Field
I would like to create a View to display the number of routes for each "Difficulty Grade"
i.e.
- 2 Routes graded 4
- 10 Routes graded 5
- 15 Routes graded 6
- 7 Routes graded 7
I have attached a screenshot of the view I created for this. Could you help me understanding what to correct?
Ivan
Hello,
I assume we are talking about this case:
- post type "Routes",
- custom number field "Difficulty Grade"
For example:
Routes A, Difficulty Grade: 3
Routes B, Difficulty Grade: 4
Routes C, Difficulty Grade: 4
You are going to display post counts for each "Difficulty Grade", like this:
Difficulty Grade "3“: 1 "Routes" post found
Difficulty Grade "4“: 2 "Routes" post found
If it is, it is possible within Views plugin, you can create a post view, query "Routes" posts, filter on custom field "Difficulty Grade" by shortcode attribute, for example "difficultygrade"
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/#source-for-compare-value
And display only the shortcode [wpv-items-count]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count
Then display the same view multiple times, like this:
[wpv-view name="users" difficultygrade="3"]
[wpv-view name="users" difficultygrade="4"]
https://toolset.com/documentation/user-guides/passing-arguments-to-views/#accessing-the-arguments
Hi Luo,
thank you so much for your assistance.
I have followed your instructions but found a problem.
If I create a view to display the shortcode [wpv-items-count], it works fine as long as the custom field type is a string on a *single line*. Unfortunately the custom field "Difficulty Grade" is a *Select* type.
Is there a way around this?
Also, when using the shortcode [wpv-view name="users" nameexample="John"]
Instead of searching a field *equal to* would it be possible to search *contains* ???
Thanks so much
Ivan
Dear Ivan,
Q1) the custom field "Difficulty Grade" is a *Select* type, Is there a way around this?
Yes, you just need to setup the attribute "difficultygrade" value as the option's "Custom field content" value, you can get the "Custom field content" value by edit the custom select field "Difficulty Grade", see screesnhot Custom-field-content.JPG
Q2) Instead of searching a field *equal to* would it be possible to search *contains* ?
You can edit the view, setup the custom field filter "Comparison function" as "LIKE", see the document I mentioned above:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/#comparison-function
LIKE Single value Checks if the custom field value is similar to the compare value, using MySQL LIKE operator
My issue is resolved now. Thank you!