I have a custom field called post_views_count which stores the views of each post on my blog. I would like to use these views to decide which category the posts belong. Here is what I would like to happen:
- Put the latest 50 posts into groups of 10.
- Find which post in each group has the highest views and move them to the large category.
- Find the average of the remaining 9 posts in each group.
- Posts which are below the average of each group are moved to the small category and posts above the average are moved to the medium category.
This should result in 1 large post, 4 or 5 medium and 4 or 5 small posts per group. This process would run on a cron every hour to refresh the categories as well as running each time a new post is made. When a post leaves the latest 50 it just remains the category it was last assigned.
I've looked around for similar solutions and I'm not able to find much. Any help would be much appreciated.