feat(Wordpress Node): Add date fields (#17755)

Co-authored-by: Shireen Missi <shireen@n8n.io>
This commit is contained in:
RomanDavydchuk
2025-07-29 19:23:02 +03:00
committed by GitHub
parent 164800f6a4
commit 724b5a51f2
5 changed files with 33 additions and 8 deletions

View File

@@ -134,6 +134,13 @@ export const postFields: INodeProperties[] = [
default: 'draft', default: 'draft',
description: 'A named status for the post', description: 'A named status for the post',
}, },
{
displayName: 'Date',
name: 'date',
type: 'dateTime',
default: '',
description: "The date the post was published, in the site's timezone",
},
{ {
displayName: 'Comment Status', displayName: 'Comment Status',
name: 'commentStatus', name: 'commentStatus',
@@ -413,6 +420,13 @@ export const postFields: INodeProperties[] = [
default: 'draft', default: 'draft',
description: 'A named status for the post', description: 'A named status for the post',
}, },
{
displayName: 'Date',
name: 'date',
type: 'dateTime',
default: '',
description: "The date the post was published, in the site's timezone",
},
{ {
displayName: 'Comment Status', displayName: 'Comment Status',
name: 'commentStatus', name: 'commentStatus',

View File

@@ -1,4 +1,5 @@
export interface IPost { export interface IPost {
date?: string;
author?: number; author?: number;
id?: number; id?: number;
title?: string; title?: string;

View File

@@ -187,6 +187,9 @@ export class Wordpress implements INodeType {
if (additionalFields.format) { if (additionalFields.format) {
body.format = additionalFields.format as string; body.format = additionalFields.format as string;
} }
if (additionalFields.date) {
body.date = additionalFields.date as string;
}
responseData = await wordpressApiRequest.call(this, 'POST', '/posts', body); responseData = await wordpressApiRequest.call(this, 'POST', '/posts', body);
} }
//https://developer.wordpress.org/rest-api/reference/posts/#update-a-post //https://developer.wordpress.org/rest-api/reference/posts/#update-a-post
@@ -239,6 +242,9 @@ export class Wordpress implements INodeType {
if (updateFields.format) { if (updateFields.format) {
body.format = updateFields.format as string; body.format = updateFields.format as string;
} }
if (updateFields.date) {
body.date = updateFields.date as string;
}
responseData = await wordpressApiRequest.call(this, 'POST', `/posts/${postId}`, body); responseData = await wordpressApiRequest.call(this, 'POST', `/posts/${postId}`, body);
} }
//https://developer.wordpress.org/rest-api/reference/posts/#retrieve-a-post //https://developer.wordpress.org/rest-api/reference/posts/#retrieve-a-post

View File

@@ -21,6 +21,7 @@ describe('Wordpress > Post Workflows', () => {
sticky: true, sticky: true,
categories: [1], categories: [1],
format: 'standard', format: 'standard',
date: '2025-03-27T18:30:04',
}) })
.reply(200, postCreate); .reply(200, postCreate);
mock mock
@@ -29,6 +30,7 @@ describe('Wordpress > Post Workflows', () => {
title: 'New Title', title: 'New Title',
content: 'Some new content', content: 'Some new content',
status: 'publish', status: 'publish',
date: '2025-03-27T18:05:01',
}) })
.reply(200, postUpdate); .reply(200, postUpdate);
}); });

View File

@@ -15,7 +15,7 @@
"typeVersion": 1, "typeVersion": 1,
"position": [340, 0], "position": [340, 0],
"id": "086a9b07-77ee-4c99-9d4e-05fdb63914a4", "id": "086a9b07-77ee-4c99-9d4e-05fdb63914a4",
"name": "updateResponse" "name": "Update Response"
}, },
{ {
"parameters": { "parameters": {
@@ -24,7 +24,8 @@
"updateFields": { "updateFields": {
"title": "New Title", "title": "New Title",
"content": "Some new content", "content": "Some new content",
"status": "publish" "status": "publish",
"date": "2025-03-27T18:05:01"
} }
}, },
"type": "n8n-nodes-base.wordpress", "type": "n8n-nodes-base.wordpress",
@@ -103,14 +104,15 @@
"pingStatus": "closed", "pingStatus": "closed",
"format": "standard", "format": "standard",
"sticky": true, "sticky": true,
"categories": [1] "categories": [1],
"date": "2025-03-27T18:30:04"
} }
}, },
"type": "n8n-nodes-base.wordpress", "type": "n8n-nodes-base.wordpress",
"typeVersion": 1, "typeVersion": 1,
"position": [120, 400], "position": [120, 400],
"id": "3a022ad5-8ce7-4ff2-988f-a449c7f1466e", "id": "3a022ad5-8ce7-4ff2-988f-a449c7f1466e",
"name": "Post Create", "name": "Post > Create",
"credentials": { "credentials": {
"wordpressApi": { "wordpressApi": {
"id": "vNOAnwp9mSIq39cD", "id": "vNOAnwp9mSIq39cD",
@@ -128,7 +130,7 @@
} }
], ],
"pinData": { "pinData": {
"updateResponse": [ "Update Response": [
{ {
"json": { "json": {
"id": 1, "id": 1,
@@ -711,7 +713,7 @@
"index": 0 "index": 0
}, },
{ {
"node": "Post Create", "node": "Post > Create",
"type": "main", "type": "main",
"index": 0 "index": 0
} }
@@ -722,7 +724,7 @@
"main": [ "main": [
[ [
{ {
"node": "updateResponse", "node": "Update Response",
"type": "main", "type": "main",
"index": 0 "index": 0
} }
@@ -751,7 +753,7 @@
] ]
] ]
}, },
"Post Create": { "Post > Create": {
"main": [ "main": [
[ [
{ {