两个 wordpress 站点在同一个数据库上使用不同的主题 [英] Two wordpress sites using diiferent themes on the same database

查看:45
本文介绍了两个 wordpress 站点在同一个数据库上使用不同的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从同一个数据库运行 2 个 wordpress 站点,one.site.comtwo.site.com.除了主题之外,一切都保持不变.

I want to run 2 wordpress sites, one.site.com and two.site.com from the same database. Everything remains the same except for the theme.

  • one.site.com - 现有网站
  • two.site.com - 应该使用 one.site.com 的数据库,除了主题

有什么办法可以做到吗?

Is there any way this can be done ?

由于主题详细信息存储在 wp_options 表中,two.site.com 是否可以使用它来显示不同的主题?说复制那个表并让 two.site.com 使用它?

Since theme details are stored in wp_options table is it possible for two.site.com to use it to display a different theme ? Say duplicating that table and making two.site.com use it ?

感谢您的帮助.

两个网站都没有任何插件.

Both the sites do not have any plugins.

推荐答案

下面的解决方案对我有用,

The solution below did the job for me,

在一个数据库上安装 2 个 WordPress 网站.

Install 2 WordPress sites on a single database.

在您的数据库中创建新表.将其命名为 wp_options2 并将 wp_options 中的所有内容复制到此新表中

Create new table in your database. Call it wp_options2 and copy everything from wp_options into this new table

在第二次安装中转到 wp-config.php,并在 if (!defined('ABSPATH')) 之前添加 define('M7_OPTIONS_TABLE', 'wp_options2');

In second install go to wp-config.php, and before if (!defined('ABSPATH')) add define( 'M7_OPTIONS_TABLE', 'wp_options2');

在第二次安装中,转到第 1009 行的 wp-includes/wp-db.php 并添加代码:

In second install go to wp-includes/wp-db.php on line 1009 and add code:

if (isset( $tables['options'] ) && defined('M7_OPTIONS_TABLE')) $tables['options'] = M7_OPTIONS_TABLE;

这些代码应该添加在public function tables函数中,在if (isset( $tables['users']) && defined('CUSTOM_USER_TABLE')))之前

These codes should be added in public function tables function, before if (isset( $tables['users']) && defined('CUSTOM_USER_TABLE')))

我在这里找到了这个解决方案,https://wordpress.stackexchange.com/questions/84313/how-to-run-two-wordpress-blogs-with-different-themes-and-with-single-database-an#answer-175494

I found this solution here, https://wordpress.stackexchange.com/questions/84313/how-to-run-two-wordpress-blogs-with-different-themes-and-with-single-database-an#answer-175494

由于我们使用相同的数据库,因此两个站点上的链接将相同.我链接了很多图片,我使用

Since we use the same database, links will be same on both the sites. I had a lot of images linked and I removed them using

.single a[href$=".jpg"] {
    pointer-events: none;
    cursor: default;  
} 

这篇关于两个 wordpress 站点在同一个数据库上使用不同的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆