• Resolved Prolet

    (@prolet)


    Hello πŸ™‚
    First I’d like to apologise if the subject was discussed but I was unable to find an answer!

    I have subdomains network. Every subdomain is a different woocommerce shop.

    Is it possible to have on the main site a a gallery of all shops? I suppose I can do it manually πŸ™‚ The idea is how to link all subdomains to be shown on the main site.

    Thank you very much for your response!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    There is a function, wp_get_sites(), that will return an array of all network sites. You could loop through this, switch to each site temporarily using switch_to_blog() and then pull the products for that site.

    Pseudo code:

    $sites = wp_get_sites();
    foreach ( $sites as $site ) {
      switch_to_blog( $site['blog_id'] );
      // Display your products here
      restore_current_blog(); // Important!
    }

    Thanks,

    Thread Starter Prolet

    (@prolet)

    Dear karpstrucking,
    Thank you so much for your reply. Your contribution is priceless!
    I will use the code today.
    πŸ™‚

    Thread Starter Prolet

    (@prolet)

    Dear karpstrucking,

    It didn’t work πŸ™

    Or (more possible) I didn’t do the proper job.

    Sorry, but I am not PHP savvy.

    How to pull up the subdomains? I can’t see a way!

    If you, please?!

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘A gallery from all subdomains’ is closed to new replies.