Create a Post
Post data
Wraps post data object. See WP_REST_Posts_Controller::prepare_item_for_response for the reference of post object contents: https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Create a Post and get ID
cy.createPost({ title: 'Test Post', content: 'Test Content'}).then(post => { const id = post.id;}); Copy
cy.createPost({ title: 'Test Post', content: 'Test Content'}).then(post => { const id = post.id;});
Create a Post with draft status.
cy.createPost({ title: 'Test Post', content: 'Test Content', status: 'draft'}) Copy
cy.createPost({ title: 'Test Post', content: 'Test Content', status: 'draft'})
Create a Page
cy.createPost({ postType: 'page' title: 'Test page', content: 'Page Content'}) Copy
cy.createPost({ postType: 'page' title: 'Test page', content: 'Page Content'})
Perform custom actions before saving the post
cy.createPost({ title: 'Post Title', beforeSave: () => { // Change additional metaboxes. }}) Copy
cy.createPost({ title: 'Post Title', beforeSave: () => { // Change additional metaboxes. }})
Create a Post