Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 是否可以将多站点主站点产品显示到子站点?_Wordpress_Multisite - Fatal编程技术网

Wordpress 是否可以将多站点主站点产品显示到子站点?

Wordpress 是否可以将多站点主站点产品显示到子站点?,wordpress,multisite,Wordpress,Multisite,我想创建一个多站点项目,其中主站点可以创建woocommerce项目,也可以在主站点上添加产品。它也将在子网站上显示。我试过那样做,但没有表现出来。这在wordpress中可能吗?是的,您可以切换到主站点,查询任何需要的内容,然后还原。 在子站点主题中,执行以下操作: $main_site_id = 1; //use your main site id switch_to_blog( $main_site_id ); //write any code as if you are in your

我想创建一个多站点项目,其中主站点可以创建woocommerce项目,也可以在主站点上添加产品。它也将在子网站上显示。我试过那样做,但没有表现出来。这在wordpress中可能吗?

是的,您可以切换到主站点,查询任何需要的内容,然后还原。 在子站点主题中,执行以下操作:

$main_site_id = 1; //use your main site id
switch_to_blog( $main_site_id );
//write any code as if you are in your main website
restore_current_blog();
//use the data you fetched in your current child site.
注意:如果您要编写与woocommerce相关的代码。在您的子站点中安装woocommerce插件时,请确保安全