Contents
On this page

Create Shortcode - Plugixa Testimonial

POST /plugixatestimonial/v1/shortcodes

Save a shortcode configuration, then place it with [plugixa_testimonial id="..."].

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/shortcodes

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 What to show.

config is merged over the defaults: view_id null (the default view), categories [] (all), limit -1 (all), orderby display_order, order ASC, featured_only false, min_rating 0, every display toggle on except showWebsite, and schema true. orderby takes display_order, created_at, rating or client_name. Values are stored as sent.

{
  "name": "Agency reviews",
  "description": "Top agency testimonials.",
  "config": {
    "view_id": 2,
    "categories": [
      3
    ],
    "limit": 6,
    "min_rating": 4
  }
}

Responses

200 OK. data.id is the new shortcode.

{
  "success": true,
  "message": "Shortcode created successfully",
  "data": {
    "id": 7
  }
}
Field Type Meaning
data.id integer The new shortcode’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/shortcodes" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Agency reviews","description":"Top agency testimonials.","config":{"view_id":2,"categories":[3],"limit":6,"min_rating":4}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/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'        => 'Agency reviews',
        'description' => 'Top agency testimonials.',
        'config'      => [
            'view_id'    => 2,
            'categories' => [3],
            'limit'      => 6,
            'min_rating' => 4,
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/shortcodes', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Agency reviews', description: 'Top agency testimonials.', config: { view_id: 2, categories: [3], limit: 6, min_rating: 4 } }),
});
const { data } = await response.json();

Quick Links

Share