Contents
On this page
Link Translations - Plugixa FAQ
PUT /plugixa-faq/v1/multilingual/{entity}/link-translations
Make two existing items translations of each other.
Any signed-in user with the plugixa_faq_edit capability or WordPress’s edit_posts (Contributors and up, by default).
Note. The target joins the source’s group and leaves its own: items that were linked to the target stay in the old group. When the source’s group already has an item in the target’s language, the database refuses the link but the call still answers
200with the group. Check the result with List Translations.
Request
PUT https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/link-translations
Path parameters
| Name | Type | Description |
|---|---|---|
entity |
string |
faqs, categories or custom-fields |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
source_id |
integer |
Yes | The item whose group to use. A group is created for it if it has none. |
target_id |
integer |
Yes | The item to add to that group. Must be in a different language. |
This is the way to connect two existing items. Do not send translation_group on Update FAQ: it is ignored there.
{
"source_id": 42,
"target_id": 61
}
Responses
200 OK.
{
"success": true,
"message": "Items linked as translations.",
"data": {
"translation_group": "9b2f6c1e-4d1a-4c55-a0de-3f7f1b2c8e10"
}
}
| Field | Type | Meaning |
|---|---|---|
data.translation_group |
string |
The shared group |
Errors
| Status | Code | When |
|---|---|---|
400 |
rest_error |
“Invalid entity type.”, or “Cannot link items with the same language.” |
404 |
rest_error |
One or both items do not exist. |
400 |
rest_missing_callback_param |
source_id or target_id is missing. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/link-translations" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"source_id":42,"target_id":61}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/link-translations');
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([
'source_id' => 42,
'target_id' => 61,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/link-translations', {
method: 'PUT',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ source_id: 42, target_id: 61 }),
});
const { data } = await response.json();
Quick Links
Share