WordPress REST Driver
ArchivedThese are the docs for ng-qubee 3.8. Read the 4.0 docs for @qubeejs/angular.
Targets the WordPress REST API — the JSON API shipped with every WordPress install since 4.7, with its collection parameters and header-carried pagination metadata.
Configure
Section titled “Configure”import { DriverEnum, provideNgQubee } from 'ng-qubee';
bootstrapApplication(AppComponent, { providers: [provideNgQubee({ driver: DriverEnum.WORDPRESS })]});Point setBaseUrl at the REST root (e.g. https://example.com/wp-json/wp/v2) and use the collection name (posts, pages, media, …) as the resource.
Wire format
Section titled “Wire format”| Concern | Output |
|---|---|
| Filters (single value) | field=value (collection params: status=publish, author=1) |
| Filters (multi-value) | field=v1,v2 (CSV — the WordPress list convention) |
| Sort | orderby=field&order=asc|desc (single sort — see below) |
| Select | _fields=id,title (CSV) |
| Includes | _embed=author,wp:term (CSV) |
| Search | search=term |
| Pagination | page=N&per_page=M |
The page / per_page / orderby / order / search keys and the underscore-prefixed global params (_fields, _embed) are fixed by the server and ignore request key overrides.
Two WordPress-specific constraints to keep in mind:
- Single sort: WordPress core accepts one
orderbyvalue, so only the first sort rule in state is emitted; additionaladdSortcalls are ignored on the wire. per_pagecap: the server rejectsper_page > 100with arest_invalid_param400. The driver keeps the standard positive-integer validation and leaves the cap to the server — stay atsetLimit(100)or below.
Operator filters
Section titled “Operator filters”WordPress has no generic comparison-operator syntax — only parameter-specific helpers (before / after for dates, slug, include / exclude ID lists), which pass through addFilter as ordinary collection params:
qb.addFilter('after', '2024-01-01T00:00:00'); // after=2024-01-01T00:00:00qb.addFilter('exclude', 12, 13); // exclude=12,13addFilterOperator therefore throws UnsupportedFilterOperatorError for every operator (the operatorFilters capability is off).
Feature matrix
Section titled “Feature matrix”| Method | Supported? | Notes |
|---|---|---|
addFilter / deleteFilters |
✓ | Bare collection params, CSV for multi-value |
addFilterOperator / deleteOperatorFilters |
✗ | No generic operator syntax |
addSort / deleteSorts |
✓ | orderby + order — first sort rule only |
setLimit / setPage |
✓ | page + per_page (server caps per_page at 100) |
addSelect / deleteSelect |
✓ | _fields= CSV |
addFields / deleteFields / deleteFieldsByModel |
✗ | No per-model field selection |
addIncludes / deleteIncludes |
✓ | _embed= CSV (embeds linked resources into _embedded) |
addEmbedded / deleteEmbedded |
✗ | Throws UnsupportedEmbeddedError |
setSearch / deleteSearch |
✓ | search=term full-text search |
Response shape
Section titled “Response shape”WordPress returns a bare array body; pagination metadata travels in HTTP response headers:
X-WP-Total: 48X-WP-TotalPages: 5Link: <https://example.com/wp-json/wp/v2/posts?page=2>; rel="next"Pass the headers to paginate() — the same call-site shape as the PostgREST driver:
this._http.get<IPost[]>(uri, { observe: 'response' }).subscribe(response => { const collection = this._pagination.paginate(response.body, response.headers);});WordpressResponseStrategy maps X-WP-Total → total and X-WP-TotalPages → lastPage, surfaces the Link URLs as nextPageUrl / prevPageUrl, and derives position from them:
pageis theprevlink’spageparam + 1 (noprev→ page 1), falling back to thenextlink’spageparam − 1.perPageis the item count of any page that has anextsuccessor (such a page is necessarily full); on the last page of a multi-page set it staysundefined.from/toderive frompage×perPageon full pages, or count back from the total on the last page (from = total - data.length + 1,to = total).
Headers are optional at the call site — without them the collection still carries the array body, with undefined totals. The bag accepts Angular’s HttpHeaders, the native Headers class, or a plain Record<string, string>.
Because all metadata is header-borne, this driver uses the plain ResponseOptions defaults; only response.data matters, and only when your HTTP layer wraps the array in an envelope.