WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a popularity calculation for all posts, based on page view and date of creation. Initially, there's a default popularity value saved in postmeta. Every hour I want to recalculate the popularity among all posts by cron job.

How can I update all post's popularity in postmeta table?

share|improve this question

You probably would have to use a script which would have to be referenced in your crontab. The problem is to calculate the final value of the popularity for each post, but if you apply the funcion the right way in the PHP script, the UPDATE operation on your MySQL database should work nicely.

Here you've got a discussion on how to apply that kind of operation (though the final values are easier to get) and there was a good discussion on this subject on StackOverflow sometime ago.

share|improve this answer

Take a look at schedule functions in Codex.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.