Contents
On this page
Update Permastructure - Plugixa Permalink Manager
PUT /plugixa-permalink-manager/v1/permastructures/{kind}/{name}
Save the address pattern of one post type or taxonomy.
Needs the plugixa_permalink_manager_manage_settings capability. POST and PATCH are accepted too.
Note. Saving a pattern moves no existing address. It decides the address of items created from now on, and of items in Update on save mode when they are saved. To apply it to existing content, run Regenerate.
Request
PUT https://your-site.example/wp-json/plugixa-permalink-manager/v1/permastructures/post_type/product
Path parameters
| Name | Type | Description |
|---|---|---|
kind |
string |
post_type or taxonomy |
name |
string |
The post type or taxonomy name |
Query parameters
| Name | Type | Default | Description |
|---|---|---|---|
language |
string |
A language code on a multilingual site, to read or write that language’s own pattern. Empty for the pattern every language falls back to |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
pattern |
string |
Yes | Literal path text and %tags%. Anything other than letters, digits, %, _, ., - and / is removed, as are .. and outer slashes. |
append_slug |
boolean |
No | Add the slug when the pattern has no slug tag. Defaults to true. Only a JSON false turns it off: 0 or "false" leave it on. |
{
"pattern": "shop/%product_cat%/%postname%",
"append_slug": true
}
Responses
200 OK. data is the content type as List Permastructures describes it.
{
"success": true,
"data": {
"kind": "post_type",
"name": "product",
"label": "Products",
"language": "",
"pattern": "shop/%product_cat%/%postname%",
"append_slug": true,
"inherited": null,
"native": "product/skyline-2",
"tags": [
{
"tag": "postname",
"label": "Post name (full path for pages)",
"group": "post"
},
{
"tag": "product_cat",
"label": "Categories (full path)",
"group": "taxonomy"
}
]
}
}
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_permalink_manager_not_found |
kind and name are not a managed content type. |
422 |
plugixa_permalink_manager_invalid_permastructure |
Nothing is left of pattern once it is cleaned. |
422 |
plugixa_permalink_manager_invalid_language |
language is not one of the site’s languages. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-permalink-manager/v1/permastructures/post_type/product" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"pattern":"shop/%product_cat%/%postname%","append_slug":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-permalink-manager/v1/permastructures/post_type/product');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'pattern' => 'shop/%product_cat%/%postname%',
'append_slug' => true,
]),
]);
$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-permalink-manager/v1/permastructures/post_type/product', {
method: 'PUT',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({ pattern: 'shop/%product_cat%/%postname%', append_slug: true }),
});
const { data } = await response.json();
Quick Links
Share