I've 2 custom posts:
- reviews
- service
There's a child-parent relationship.
Each service (parent) can display several reviews (child).
Among the custom fields, there's "rating" (number). Between 1 and 5.
For each service, I would like to show:
- total number of reviews,
- average of the ratings.
I also would like to use that for Rankmath, who has a module for schema & ratings. If not possible, then bypass Rankmath to produce a code to use schema.
Thank you for your help
Hello and thank you for contacting the Toolset support.
Toolset does not offer a built-in way to calculate sums and averages. You will need custom code to implement it. Either by using a custom shortcode inside the view or by producing a shortcode that uses the relationships API to get the child posts and calculate the results for them.
Please note that custom code is beyond the scope of the support forum. If you are not comfortable with programming, consider hiring a developer. This is the list of our partners https://toolset.com/contractors/
https://toolset.com/toolset-support-policy/
Check these previous similar threads for inspiration:
- https://toolset.com/forums/topic/is-there-any-way-to-calculate-sum-of-values-of-prticular-field-in-picked-items/#post-1310705
- https://toolset.com/forums/topic/sum-of-custom-fields-calculation/#post-1568815
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/