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?


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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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