So basically i got this custom field value which is stored in $postrating - and under the database field customfield1. I want to grab the value of that field for all posts that have the tag currently being browsed. Then i want to calculate the average value of those numbers and display on the archive.php page when browing a tag.
If its a regular custom field you can add this to your archive.php:
Now that you've mentioned that there is pagination evolved and you are not getting all of the posts (for example 10/14), you can create a new WP_Query object and use it to get all of the posts (14/14) and check the average. add this code before your loop: