A plugin to publish blogs to your WordPress website.
/create-postThe /create-post endpoint is used to create a new post with the specified title, content, status, and author.
/wp-json/sm-connect/v1/create-postPOSTapplication/jsonTo create a new post, make a POST request with the required parameters included in the query string. You must also include an Authorization header with a valid Bearer token.
| Header | Value |
|---|---|
| Authorization | Bearer <your_access_token> |
| Parameter | Type | Description |
|---|---|---|
| title | string | The title of the post. |
| content | string | The content of the post. |
| status | string | The status of the post (e.g., publish). |
| author | int | Optional. The ID of the author of the post. When omitted, the post is assigned to the Default Author saved in Post Settings, or to the first administrator when none is saved. The same user is reported as default_author by /status. |
| featured_image | string | URL of the new featured image for the post. |
| slug | string | Optional. Custom permalink slug. If omitted, WordPress generates one from the title. |
Note: Titles do not need to be unique. If a post with the same title already exists, WordPress generates a unique slug for the new post (e.g.
my-blog-post-2,my-blog-post-3), matching the behavior of the WordPress dashboard.
$http({
method: 'POST',
url: 'SITE_URL/wp-json/sm-connect/v1/create-post',
headers: {
'Authorization': 'Bearer <your_access_token>',
'Content-Type': 'application/json'
},
data: {
title: 'Sample Title',
content: 'Sample content',
status: 'publish',
author: 1,
slug: 'my-custom-slug'
}
}).then(function successCallback(response) {
console.log('Post created:', response.data.data);
}, function errorCallback(response) {
console.error('Error:', response.data.message);
});