Contents
On this page

Create Category - Plugixa FAQ

POST /plugixa-faq/v1/categories

Create a category to group FAQs.

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

Request

POST https://your-site.example/wp-json/plugixa-faq/v1/categories

Request body

Content type: application/json

Field Type Required Description
name string Yes Plain text, at least 2 characters.
slug string No Made from the name when empty. Made unique by appending -1, -2, …
description string No Plain text; line breaks are kept.
icon string No Icon name shown with the category.
color string No Hex colour such as #2271b1. Anything else is stored as null.
menu_order integer No Position in manual ordering. Defaults to 0.
feedback_enabled boolean No Whether FAQs in this category show the feedback widget PRO when they do not decide for themselves. Defaults to true.
language_code string No With WPML or Polylang active only: the category’s language.
translation_group string No With WPML or Polylang active only: join an existing translation group.

See Categories.

{
  "name": "Shipping",
  "description": "Delivery times and costs.",
  "color": "#2271b1"
}

Responses

200 OK. data.id is the new category.

{
  "success": true,
  "message": "Category created successfully",
  "data": {
    "id": 3
  }
}
Field Type Meaning
data.id integer The new category’s id
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_missing_callback_param name is missing.
400 rest_error “Validation failed”: the name is empty or shorter than 2 characters. data.errors.name says which.
500 rest_error The database refused the row.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-faq/v1/categories" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Shipping","description":"Delivery times and costs.","color":"#2271b1"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/categories');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'name'        => 'Shipping',
        'description' => 'Delivery times and costs.',
        'color'       => '#2271b1',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/categories', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Shipping', description: 'Delivery times and costs.', color: '#2271b1' }),
});
const { data } = await response.json();

Quick Links

Share