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

I have network of sites, and I need to import data into them via a cron job. Obviously wp_insert_post is meaningless in this case, since i'm not in a blog...i'm in a cron script. I also read that switch_to_blog is deprecated, yet I can't find any alternative. How do I set the blog to post to?

share|improve this question
up vote 1 down vote accepted

switch_to_blog isn't deprecated anymore. You can use it just fine. However, it does have a bit of overhead, so you want to use it as little as possible.

share|improve this answer

Actually the solution is much easier than this....$wpdb->set_blog_id($blog_id); does exactly what I need it to do.

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.