Contents
On this page

Update Category - Plugixa Testimonial

PUT /plugixatestimonial/v1/categories/{id}

Replace a category’s fields.

Any signed-in user with the plugixa_testimonial_edit capability or WordPress’s edit_posts (Contributors and up, by default).

Note. This is a full replace. A field you leave out is reset: description to empty, display_order to 0, status to publish, and an omitted slug is saved empty. Because slugs are unique, a second category saved without a slug then fails with 500. Always send slug.

Note. There is no existence check: an id that matches nothing still answers 200 with the success message, and nothing changes.

Request

PUT https://your-site.example/wp-json/plugixatestimonial/v1/categories/3

Path parameters

Name Type Description
id integer The category’s id

Request body

Content type: application/json

Field Type Required Description
name string Yes Plain text, must not be blank.
slug string No Made from the name when empty. Made unique by appending -1, -2, …
description string No Plain text.
display_order integer No Defaults to 0.
status string No publish (the default), draft or trash. Any other value is saved as publish.

A slug that another category already uses is made unique by appending -1, -2, … With WPML or Polylang active, display_order and status are copied to every translation.

{
  "name": "Agencies",
  "description": "Feedback from agency clients.",
  "display_order": 0,
  "status": "publish",
  "slug": "agencies"
}

Responses

200 OK.

{
  "success": true,
  "message": "Category updated successfully",
  "data": {
    "id": 3
  }
}
Field Type Meaning
data.id integer The id you sent
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_error “Validation failed”. data.errors names the field: name.
500 rest_error The database refused the update.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixatestimonial/v1/categories/3" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Agencies","description":"Feedback from agency clients.","display_order":0,"status":"publish","slug":"agencies"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/categories/3');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'name'          => 'Agencies',
        'description'   => 'Feedback from agency clients.',
        'display_order' => 0,
        'status'        => 'publish',
        'slug'          => 'agencies',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/categories/3', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Agencies', description: 'Feedback from agency clients.', display_order: 0, status: 'publish', slug: 'agencies' }),
});
const { data } = await response.json();

Quick Links

Share