Contents
Create Shortcode - Plugixa FAQ
POST /plugixa-faq/v1/shortcodes
Save a new shortcode configuration.
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/shortcodes
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | At least 2 characters. |
slug |
string |
No | Made from the name when empty, and then made unique. A slug you send must not be taken already. |
description |
string |
No | Plain text. |
config |
object |
No | The settings, in the shape Get Shortcode returns. Merged over the defaults, so you can send only the keys you change. |
{
"name": "Shipping FAQ",
"config": {
"view": "support-centre",
"categories": [
"shipping"
],
"search": true
}
}
Responses
200 OK. data.id is the new shortcode.
{
"success": true,
"message": "Shortcode created successfully",
"data": {
"id": 12
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
Use it as [plugixa_faq id="12"] |
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 shorter than 2 characters, or the slug is taken. |
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/shortcodes" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Shipping FAQ","config":{"view":"support-centre","categories":["shipping"],"search":true}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/shortcodes');
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 FAQ',
'config' => [
'view' => 'support-centre',
'categories' => ['shipping'],
'search' => true,
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/shortcodes', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Shipping FAQ', config: { view: 'support-centre', categories: ['shipping'], search: true } }),
});
const { data } = await response.json();
Quick Links
Share