Batch-assign posts to a section
const url = 'https://example.com/wp-json/wp2/course-manager/v1/assign';const options = { method: 'PUT', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"ids":[1],"sectionId":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://example.com/wp-json/wp2/course-manager/v1/assign \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "ids": [ 1 ], "sectionId": 1 }'Assigns a batch of posts (ids) to sectionId. sectionId=null clears the assignment (unassigned).
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Array of numeric post IDs.
Section ID; null clears the assignment.
Example
{ "ids": [ 1 ], "sectionId": 1}Responses
Section titled “Responses”OK
object
Whether the operation succeeded.
Course Manager items.
object
Numeric entity id.
Human-readable name.
Slug (site, post, or section).
Count.
Sort order.
Section icon.
Total posts of this type.
How many posts have no section.
Examplegenerated
{ "ok": true, "sections": [ { "id": 1, "name": "example", "slug": "example", "count": 1, "order": 1, "icon": "example" } ], "allCount": 1, "unassigned": 1}Wp2sf_bad_post_type / wp2sf_empty_ids
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Not authenticated. WordPress REST: rest_not_logged_in / rest_forbidden. Use cookie + X-WP-Nonce or Application Password.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Insufficient capability or invalid REST nonce. WordPress REST: rest_forbidden / rest_cookie_invalid_nonce.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}