CtrlField registers REST endpoints for reading and writing field data. Fields must have ->showInRest(true) to appear in REST responses.
Namespace: ctrlfield/v1
Returns field values for a post.
Authentication: Requires a valid WP authentication method (cookie + nonce, application password, or JWT).
Response:
{
"post_id": 42,
"fields": {
"client_name": "Acme Corp",
"project_type": "web",
"launch_date": "2026-06-01",
"hero_image": 155
}
}Updates field values for a post. The request body is a JSON object of field key → value pairs.
Request:
{
"client_name": "New Client",
"project_type": "brand"
}Response: Same as GET, reflecting the updated values.
Same structure as post endpoints. Requires edit_user capability for other users.
Requires the taxonomy-specific edit_terms capability.
AJAX post search used by the Post Object and Relationship fields.
| Parameter | Type | Description |
|---|---|---|
search |
string | Search term |
post_type |
string | Post type to search (must be a registered public type) |
per_page |
int | Max results (1–100, default 20) |
AJAX term search used by the Taxonomy Term field.
| Parameter | Type | Description |
|---|---|---|
search |
string | Search term |
taxonomy |
string | Taxonomy slug |
per_page |
int | Max results (default 20) |
AJAX user search used by the User field.
| Parameter | Type | Description |
|---|---|---|
search |
string | Search term |
roles |
string | Comma-separated role slugs to filter |
per_page |
int | Max results (default 20) |
Field::text('client_name')
->label('Client Name')
->showInRest(true), // ← this makes it appear in /v1/post/{id}Fields without showInRest(true) are never included in REST responses, regardless of authentication.
Using an Application Password:
curl -X GET \
https://example.com/wp-json/ctrlfield/v1/post/42 \
-u "username:application-password"Using cookie auth + nonce (JavaScript):
const response = await fetch('/wp-json/ctrlfield/v1/post/42', {
headers: {
'X-WP-Nonce': wpApiSettings.nonce,
},
});
const data = await response.json();
console.log(data.fields.client_name);