Repository navigation
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'));| 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.
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/blogCore 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.
Getting started
- Usage
- Bootstrap and Configuration
- Authorization
- Browser Sign-In
- WordPress.com and Jetpack
- Multisite
- Supported REST Methods
Requests and data
- Sending Requests
- Error Handling and Responses
- Fluent Queries
- Interfaces and Extensions
- Custom Post Types
- Model Generator
- Meta and ACF
- Concurrent Edits
- Batch Requests
- Embed and Fields
- Pagination and Finders
- Parallel Requests
- Streaming and Polling
- Pattern Directory Items
Behaviour
- Retries
- Caching
- Request De-duplication and Concurrency
- Middlewares
- Logging
- Offline Write Queue
- Events and Statistics
Other APIs
Extend and test
Reference