开发者

Accessing original WordPress blog's DB from sub-blogs in network mode

开发者 https://www.devze.com 2023-02-01 04:59 出处:网络
I\'m helping with a university radio station website that runs WordPress and was recently switched over to Network (Multi-site/multi-user) mode by myself. The setup is as such:

I'm helping with a university radio station website that runs WordPress and was recently switched over to Network (Multi-site/multi-user) mode by myself. The setup is as such:

  1. The parent site (www.stationID.com) runs a bunch of custom-built plugins to construct things like the show schedule calendar, the "Now Playing" widget, podcast list, et cetera.

  2. The new network websites ("wiki.stationID.com", "buddypress.stationID.com" for instance) run the same template as the parent site, but it stops after rendering the first section because the widgets from point 1 grab data from the main site's database that is not available to sub-blogs.

My question is: how do I get data from the main site's tables on the sub-domain sub-blogs? A related question is: how do I set the $wpdb->prefix to be the same as the parent site on the child websites without it negativ开发者_StackOverflow中文版ely effecting how the child website pulls data from its own database?

Any help would be awesome, thanks!


Wrap that data in a switch_to_blog function. Yes, it's deprecated but there's no replacement at the moment. :)

do stuff from main blog

0

精彩评论

暂无评论...
验证码 换一张
取 消