Skip to content

Multisite

Arun Prakash edited this page Nov 3, 2026 · 1 revision

Multisite

A WordPress multisite network serves each site under its own path (example.com/shop/) or subdomain (shop.example.com), each with its own REST API. forNetworkSite makes a client for another site of the network with the same settings.

final network = WordpressClient.forSite(
  siteUrl: Uri.parse('https://example.com'),
  bootstrapper: (b) => b
      .withRetryPolicy(const RetryPolicy.standard())
      .withDefaultAuthorization(auth)
      .build(),
);

// sub-directory network: relative to network.siteUrl
final shop = network.forNetworkSite(
  Uri.parse('/shop/'),
  bootstrapper: (b) => b.withDefaultAuthorization(auth).build(),
);

// sub-domain network: absolute URL
final blog = network.forNetworkSite(Uri.parse('https://blog.example.com'));

What is copied

Copied Not copied
Timeouts, default headers, user agent Default authorization
Retry policy, de-duplication, max concurrent requests Middlewares (cache, offline queue, logging, your own)
Dio interceptors, the HTTP adapter Interfaces added with register

Authorization and middlewares hold per-site state (tokens, cached responses, queued writes), so add them again in bootstrapper. It receives a builder that already has the copied settings.

On a network, an application password belongs to the user, so the same one normally works on every site the user is a member of.

siteUrl

client.siteUrl is the site's address, the base URL without /wp-json/...:

WordpressClient.forSite(siteUrl: Uri.parse('https://example.com/blog')).siteUrl  // https://example.com/blog

Listing the sites of a network

Core WordPress has no REST route that lists the sites of a network. Keep the list in your app, or add a route with a plugin and read it with client.raw or client.resource.

Clone this wiki locally