Contents
On this page

Update Custom Field - Plugixa FAQ

PUT /plugixa-faq/v1/custom-fields/{id}

Change some fields of a custom field definition. Fields you leave out keep their values.

Administrators only: the user needs the plugixa_faq_settings capability or WordPress’s manage_options. Needs Plugixa FAQ Pro: the free build does not register this route, so it answers 404 there.

Note. Changing field_key renames the stored values on every FAQ to the new key, so they stay attached to the field.

Request

PUT https://your-site.example/wp-json/plugixa-faq/v1/custom-fields/5

Path parameters

Name Type Description
id integer The field’s id

Request body

Content type: application/json

Field Type Required Description
field_key string No Machine name, unique (per language with WPML or Polylang). Lower-cased; only letters, digits, _ and - are kept.
field_label string No Label shown to editors and visitors.
field_type string No text (the default), textarea, url, number, date, select, checkbox or color. Anything else becomes text.
field_options array No The choices of a select field.
placeholder string No Placeholder text.
is_required boolean No Whether editors must fill it in. Defaults to false.
show_in_frontend boolean No Whether visitors see the value. Defaults to true.

Only the fields you send change. menu_order cannot be set here.

{
  "field_label": "Warranty period",
  "is_required": true
}

Responses

200 OK.

{
  "success": true,
  "message": "Custom field updated",
  "data": {
    "id": 5
  }
}
Field Type Meaning
data.id integer The id from the path
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
404 rest_error No field with that id.
400 rest_error “A field with this key already exists”.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-faq/v1/custom-fields/5" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"field_label":"Warranty period","is_required":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/custom-fields/5');
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([
        'field_label' => 'Warranty period',
        'is_required' => true,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/custom-fields/5', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ field_label: 'Warranty period', is_required: true }),
});
const { data } = await response.json();

Quick Links

Share