通过网络方式从子博客访问原始WordPress博客的数据库

发布于 2024-10-08 20:46:32 字数 446 浏览 1 评论 0原文

我正在帮助一个运行 WordPress 的大学广播电台网站,最近我自己切换到了网络(多站点/多用户)模式。设置如下:

  1. 父站点 (www.stationID.com) 运行一堆定制插件来构建诸如节目时间表日历、“正在播放”小部件、播客列表等内容。< /p>

  2. 新的网络网站(例如“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:

  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 negatively effecting how the child website pulls data from its own database?

Any help would be awesome, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯寂 2024-10-15 20:46:32

将该数据包装在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文