通过网络方式从子博客访问原始WordPress博客的数据库
我正在帮助一个运行 WordPress 的大学广播电台网站,最近我自己切换到了网络(多站点/多用户)模式。设置如下:
父站点 (www.stationID.com) 运行一堆定制插件来构建诸如节目时间表日历、“正在播放”小部件、播客列表等内容。< /p>
新的网络网站(例如“wiki.stationID.com”、“buddypress.stationID.com”)运行与父网站相同的模板,但它在渲染第一部分后停止,因为来自点 1 的小部件抓取来自主站点数据库的数据不适用于子博客。
我的问题是:如何从子域子博客上的主站点表中获取数据?一个相关的问题是:如何将 $wpdb->prefix
设置为与子网站上的父网站相同,而不会对子网站从其自己的数据库中提取数据的方式产生负面影响?
任何帮助都会很棒,谢谢!
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:
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.
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 negatively effecting how the child website pulls data from its own database?
Any help would be awesome, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将该数据包装在 switch_to_blog 函数中。是的,它已被弃用,但目前没有替代品。 :)
从主博客做事
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