Interface PostOperations
- All Known Subinterfaces:
WpRestClient
- All Known Implementing Classes:
ApacheWpRestClient,WpBaseRestClient
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 TypeMethodDescriptioncreatePost(@NonNull WpPostCreateUpdateRequest creationRequest) Creates a new post.deletePost(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.listPosts(@NonNull WpPagingQuery pageQuery, WpPostQuery postQuery) Retrieves a paginated list of posts using optional filtering and sorting criteria.trashPost(long id) Moves a post to the trash by its unique identifier.updatePost(long id, @NonNull WpPostCreateUpdateRequest updateRequest) Updates an existing post.
-
Method Details
-
createPost
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
-
deletePost
Permanently deletes a post by its unique identifier.- Parameters:
id- the ID of the post to delete- Returns:
- the post deletion response
-
getPost
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
-
getPost
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
-
listPosts
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
-
trashPost
Moves a post to the trash by its unique identifier.- Parameters:
id- the ID of the post to trash- Returns:
- the trashed
WpPost
-
updatePost
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
-