WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

There's a "Jobs" section on my website (custom post type), with various associated taxonomies (language spoken, type of contract, location, etc.) The website also has a very big user base (about 10 000 subscribers). These users have access to a form where they chose "jobs" criterias they are interested in, in order to receive a daily email with the list of "jobs" that correspond to their criterias.

I'd like to have your opinion on the best way to implement that functionality.

My first approach is this :

  1. Loop through all the "subscriber" users
  2. For each user, get the criterias they have chosen (language, type of contract, city, etc.)
  3. with these criterias, make a WP_Query on all the "jobs" published that day
  4. send the results by email

This function would be triggered daily thanks to wp cron.

My worry is that this is perhaps a very ressource intensive way (that's a loop executing 10 000 different wp_queries in a row!) The website is hosted on a dedicated webserver (quad core with about 8Gigs of ram)

Is there a more efficient way ?

share|improve this question
up vote 1 down vote accepted

Make the user query when the job is submitted and put all matching subscribers in a queue. At the end of the day run through the queue once and send the mails.

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.