I have created a custom post type named “Rating” that I’m using to add customer rating sections to my website. Each rating post has the ability to have a:
- Comment section
- Featured Photo
- and I’m using custom fields to add 1-5 ratings for Professional Rating, Efficiency Rating, and Referral Rating.
I can pull in the Rating posts based upon their associated tags no problem and I can also pull in all of the custom field data with no problem.
That being said, I’m also wanting to include the average overall rating for each custom field rating. How would I aggregate or get all of the custom field data for a single tag?
I have a tag named company
There are 50 Rating posts that have the company tag associated with them and each post has the 1-5 ratings for Professional Rating, Efficiency Rating, and Referral Rating.
How can I get or query the DB such that I can get the average rating for say the Professional Rating custom field type for all of those posts associated with the company tag?
Hopefully this makes sense and I have explained my question clear enough but please let me know if I can further clarify.