Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.