Contents
Create View - Plugixa Testimonial
POST /plugixatestimonial/v1/views
Save a new view. There is no limit on how many a site may have.
Any signed-in user with the plugixa_testimonial_edit capability or WordPress’s edit_posts (Contributors and up, by default).
Request
POST https://your-site.example/wp-json/plugixatestimonial/v1/views
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 -1, -2, … |
description |
string |
No | Plain text. |
config |
object |
No | The design. Defaults to the built-in grid design shown in Get View. |
is_default |
boolean |
No | Defaults to false. true makes this the default view and clears the flag on the previous one. |
config is merged over the built-in defaults, so you can send only the groups and keys you change. Colors, sizes, keywords and fonts are checked, and an invalid value is dropped so the default applies. Google fonts the view uses are downloaded to the site.
{
"name": "Homepage grid",
"description": "Three columns for the home page.",
"config": {
"layout": {
"style": "grid",
"columns": {
"desktop": 3
}
},
"colors": {
"starColor": "#f59e0b"
}
}
}
Responses
200 OK. data.id is the new view.
{
"success": true,
"message": "View created successfully",
"data": {
"id": 2
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The new view’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”. data.errors names the field: name (blank). |
500 |
rest_error |
The database refused the insert. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixatestimonial/v1/views" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Homepage grid","description":"Three columns for the home page.","config":{"layout":{"style":"grid","columns":{"desktop":3}},"colors":{"starColor":"#f59e0b"}}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/views');
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' => 'Homepage grid',
'description' => 'Three columns for the home page.',
'config' => [
'layout' => [
'style' => 'grid',
'columns' => [
'desktop' => 3,
],
],
'colors' => [
'starColor' => '#f59e0b',
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/views', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Homepage grid', description: 'Three columns for the home page.', config: { layout: { style: 'grid', columns: { desktop: 3 } }, colors: { starColor: '#f59e0b' } } }),
});
const { data } = await response.json();
Quick Links
Share