Wordpress 是否可以将多站点主站点产品显示到子站点?
我想创建一个多站点项目,其中主站点可以创建woocommerce项目,也可以在主站点上添加产品。它也将在子网站上显示。我试过那样做,但没有表现出来。这在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
$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插件时,请确保安全