Contents
On this page

Create FAQ - Plugixa FAQ

POST /plugixa-faq/v1/faqs

Create a FAQ: a question, its answer and where it sits.

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

Note. category_id, parent_id and image_id are stored as sent: an id that does not exist is not rejected.

Request

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

Request body

Content type: application/json

Field Type Required Description
question string Yes Plain text, at least 5 characters. HTML tags are stripped.
answer string Yes HTML. Tags not allowed in a WordPress post are stripped. Must not end up empty.
slug string No Made from the question when empty. Made unique by appending -2, -3, …
category_id integer No The category. 0 or omitted means no category.
status string No draft (the default) or published.
visibility string No public (the default), private or password. Only public FAQs are shown to visitors.
menu_order integer No Position in manual ordering. Defaults to 0.
parent_id integer|null No Nest this FAQ under another one. See Nested FAQs.
image_id integer|null No A Media Library attachment id shown with the answer.
author_alias string No A name to show instead of the WordPress author.
feedback_enabled boolean|null No true or false overrides the category; null or "inherit" follows the category.
custom_fields object No Custom field values, keyed by field key. An empty value removes that field from the FAQ. See Custom fields PRO.
language_code string No With WPML or Polylang active only: the FAQ’s language. Defaults to the current language.
translation_group string No With WPML or Polylang active only: join an existing translation group. Must be a string; null is rejected.

The new FAQ records you as its author. view_count and the vote counters start at 0.

{
  "question": "How long does shipping take?",
  "answer": "<p>Orders ship within 2 business days.</p>",
  "category_id": 3,
  "status": "published"
}

Responses

200 OK. data.id is the new FAQ.

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

Only the id comes back. Read the FAQ with Get FAQ.

Errors

Status Code When
400 rest_missing_callback_param question or answer is missing.
400 rest_invalid_param status or visibility is not one of the listed values, or translation_group is null.
400 rest_error “Validation failed”: the question is shorter than 5 characters, or the answer is empty after cleaning. data.errors names the field.
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/faqs" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"question":"How long does shipping take?","answer":"<p>Orders ship within 2 business days.</p>","category_id":3,"status":"published"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/faqs');
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([
        'question'    => 'How long does shipping take?',
        'answer'      => '<p>Orders ship within 2 business days.</p>',
        'category_id' => 3,
        'status'      => 'published',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/faqs', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ question: 'How long does shipping take?', answer: '<p>Orders ship within 2 business days.</p>', category_id: 3, status: 'published' }),
});
const { data } = await response.json();

Quick Links

Share