I have a type custom field which allows multiple (numeric) values for a post type. In the archive view for that post type, and in the single post template, I want to display these multiple values as a RANGE, IF there are indeed more than one value stored for that post, based on the numerical value of each item, rather than showing ALL values... OR rather than using start="1" and end="x?" since the values wont necessarily be entered in numerical order. Is there a way to do this? In the attributes for a for_each i only see a start and end option, which i assume will only operate on the order that the values were entered/saved. Is there something I can do before the for_each is called, to basically "sort" these numerical values and display only the lowest "(new first item value)" and, if more than one item value for that field, with "-(last item value)"?
I feel like i am getting sooooooo close to having my fields how i need them, for creating a post and the display of values, but i really need to be able to display these multiple item values for a types custom field as a min-max range somehow.....
It's not possible to implement this using the plugin UI, it's essentially a custom feature that would need implementing using a custom shortcode.
That shortcode would need to get all of the values of the custom field for the current post, return the only value if there is just one value, otherwise order the values and return a string constructed from the first value hyphen and the last (highest) value.
ok thanks for clarifying that getting the lowest and highest numerical values of a multiple value custom field is not possible as is with the for_each or a conditional before it somehow.... will hopefully be able to figure out how to create a custom shortcode to get it, from looks of it would have to do sort meta_values for a specified meta_key associated with the current post_id correct?
Might be something worth considering adding in to the for_each arsenal, i see for other things in the shortcode section you can filter by even or odd, first, last, etc.... and i can imagine being able to filter/sort/display based on lowest or highest for numerical values would be useful to others too....
ok thanks for clarifying that getting the lowest and highest numerical values of a multiple value custom field is not possible as is with the for_each or a conditional before it somehow.... will hopefully be able to figure out how to create a custom shortcode to get it, from looks of it would have to do sort meta_values for a specified meta_key associated with the current post_id correct?
==>
Yes, thats correct.
Might be something worth considering adding in to the for_each arsenal, i see for other things in the shortcode section you can filter by even or odd, first, last, etc.... and i can imagine being able to filter/sort/display based on lowest or highest for numerical values would be useful to others too....
==>
You are welcome to file a new feature request using the following link and our product manager will review it:
- https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/