Interface PostAPIs
- All Known Implementing Classes:
PostApiClientModule
This interface provides methods for creating, retrieving, updating, listing, trashing, and deleting
WpPost resources.
Operations support standard WordPress REST API features such as pagination, filtering, retrieval contexts, password-protected content, and partial querying.
Implementations are expected to communicate with the /wp-json/wp/v2/posts endpoint or compatible
APIs.
-
Method Summary
Modifier and TypeMethodDescriptioncreate(WpPostCreateUpdateRequest creationRequest) Creates a new post.delete(long id) Permanently deletes a post by its unique identifier.Retrieves a post by its unique identifier using the given context.Retrieves a post by its unique identifier using the given context and optional password.list(WpPagingQuery pageQuery, WpPostQuery postQuery) Retrieves a paginated list of posts using optional filtering and sorting criteria.trash(long id) Moves a post to the trash by its unique identifier.update(long id, WpPostCreateUpdateRequest updateRequest) Updates an existing post.
-
Method Details
-
create
Creates a new post.Creates a post in WordPress using the provided request payload.
- Parameters:
creationRequest- the post creation request; must not benull- Returns:
- the created
WpPost
-
delete
Permanently deletes a post by its unique identifier.- Parameters:
id- the ID of the post to delete- Returns:
- the post deletion response
-
get
Retrieves a post by its unique identifier using the given context.The context determines which fields are included in the response, for example
WpContext.VIEW,WpContext.EDIT, orWpContext.EMBED.- Parameters:
id- the ID of the post to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis used- Returns:
- the matching
WpPost
-
get
Retrieves a post by its unique identifier using the given context and optional password.The context determines which fields are included in the response, for example
WpContext.VIEW,WpContext.EDIT, orWpContext.EMBED.If the post is password protected, the provided password is used to access protected content. If the password is missing or incorrect, protected fields such as content or excerpt may be omitted or flagged as protected in the response.
- Parameters:
id- the ID of the post to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis usedpassword- the password for protected content; may benullwhen not required- Returns:
- the matching
WpPost
-
list
Retrieves a paginated list of posts using optional filtering and sorting criteria.The result set can be refined using
WpPostQuery, for example by filtering on search criteria, include or exclude lists, or sort order.- Parameters:
pageQuery- the pagination settings, including page number and page size; must not benullpostQuery- additional post query parameters; may benullwhen no extra filtering is needed- Returns:
- a paginated response containing
WpPostitems
-
trash
Moves a post to the trash by its unique identifier.- Parameters:
id- the ID of the post to trash- Returns:
- the trashed
WpPost
-
update
Updates an existing post.Updates a post in WordPress using the provided request payload.
- Parameters:
id- the ID of the post to updateupdateRequest- the post update request; must not benull- Returns:
- the updated
WpPost
-