Contents
Create Cuisine - Plugixa Recipe
POST /plugixa-recipe/v1/cuisines
Create a cuisine.
Needs the plugixa_recipe_edit capability, or WordPress’s edit_posts (Contributor and up).
Request
POST https://your-site.example/wp-json/plugixa-recipe/v1/cuisines
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 -2, -3, … |
description |
string |
No | Plain text; line breaks are kept. |
image_id |
integer |
No | Attachment id of an image. |
display_order |
integer |
No | Manual position. Default 0. |
language_code, translation_group |
string |
No | For multilingual sites. |
{
"name": "Italian",
"description": "Dishes from Italy."
}
Responses
200 OK. data is the new cuisine.
{
"success": true,
"message": "",
"data": {
"id": "9",
"name": "Italian",
"slug": "italian",
"description": "Dishes from Italy.",
"image_id": null,
"display_order": "0",
"language_code": "",
"translation_group": "",
"recipe_count": 0
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
string |
The cuisine’s id |
data.slug |
string |
Unique among cuisines |
data.description |
string|null |
Plain text |
data.image_id |
string|null |
Attachment id. image_url is added when set |
data.display_order |
string |
Manual position |
data.recipe_count |
integer |
Recipes linked to it, in any status |
data.language_code, data.translation_group |
string|null |
For multilingual sites |
The status is 200, not 201.
Errors
| Status | Code | When |
|---|---|---|
400 |
rest_error |
name is missing or blank. |
500 |
rest_error |
The cuisine could not be written. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-recipe/v1/cuisines" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Italian","description":"Dishes from Italy."}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/cuisines');
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' => 'Italian',
'description' => 'Dishes from Italy.',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-recipe/v1/cuisines', {
method: 'POST',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({"name": "Italian", "description": "Dishes from Italy."}),
});
const { data } = await response.json();
Quick Links
Share