Create LearnDash Topic
Adds a new topic to the end of a lesson in a LearnDash course, through LearnDash's course steps, so it shows under that lesson in the course builder. The topic is created as a draft that students cannot see unless publish is true. Reversible: the topic can be edited, moved or trashed in LearnDash afterwards. Get the course ID from mosmcp/learndash-list-courses; the lesson must be one of that course's lessons (create one with mosmcp/learndash-create-lesson).
Also known as: add a topic, add a sub-lesson, add a lesson part.
| Property | Value |
|---|---|
| Ability slug | mosmcp/learndash-create-topic |
| Wire tool name | mosmcp__learndash-create-topic |
| Category | LearnDash (mosmcp-learndash) |
| Plan | Pro |
Required access
| Requirement | Value |
|---|---|
| Capability | edit_posts, plus the LearnDash topic post type's create_posts capability and edit_post on the course (checked in the code) |
| Minimum default role | Contributor |
| Annotations | readOnly: false · destructive: false · idempotent: false · openWorld: false |
Input schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| course_id | integer (min 1) | Yes | — | The LearnDash course ID, as returned by mosmcp/learndash-list-courses. |
| lesson_id | integer (min 1) | Yes | — | The lesson in that course to add the topic to. |
| title | string (min length 1) | Yes | — | The topic title. |
| content | string | — | Optional topic content. HTML is saved the way the WordPress editor saves it: a user with the unfiltered_html capability can save any markup, including forms, scripts and styles, and markup a user is not allowed to save is refused with the reason rather than silently removed. Backslashes are kept. | |
| publish | boolean | false |
Publish the topic straight away. Leave false to create a draft. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| step_id | integer | Yes | |
| type | string | Yes | lesson, topic or quiz. |
| title | string | Yes | |
| status | string | Yes | |
| course_id | integer | Yes | |
| course_title | string | ||
| parent_id | integer | Yes | The course, lesson or topic the new step sits under. |
| parent_type | string | course, lesson or topic. | |
| position | integer | Its position among the parent's steps of the same kind, from 1. | |
| edit_url | string | ||
| view_url | string | ||
| warnings | object[] | Notes about the save, such as markup that could not be kept. | |
| warnings[].code | string | ||
| warnings[].message | string | ||
| warnings[].context | string | ||
| notes | string[] |
Example
Sample prompt
Add a topic called 'Handling Missing Values' under lesson 530 of LearnDash course 512.
Example request (json)
{
"jsonrpc": "2.0",
"id": 673,
"method": "tools/call",
"params": {
"name": "mosmcp__learndash-create-topic",
"arguments": {
"input": {
"course_id": 512,
"lesson_id": 530,
"title": "Handling Missing Values"
}
}
}
}Example response (json)
{
"jsonrpc": "2.0",
"id": 673,
"result": {
"isError": false,
"structuredContent": {
"step_id": 534,
"type": "topic",
"title": "Handling Missing Values",
"status": "draft",
"course_id": 512,
"course_title": "Python for Analysts",
"parent_id": 530,
"parent_type": "lesson",
"position": 1,
"edit_url": "https://example.com/wp-admin/post.php?post=534&action=edit",
"view_url": "https://example.com/?post_type=sfwd-topic&p=534",
"warnings": [],
"notes": [
"It is a draft, so students will not see it until it is published."
]
}
}
}
Edge cases / errors
- lesson_id that is not a lesson of that course → mosmcp_learndash_parent_not_found, with up to 50 of the course's lessons in valid_lessons; add one with mosmcp/learndash-create-lesson.
- No right to edit that course → mosmcp_learndash_cannot_edit_course; ID that is not a LearnDash course → mosmcp_learndash_course_not_found.
- LearnDash does not attach the topic → mosmcp_learndash_step_not_attached, and the new post is deleted again.
- Always a draft unless publish is true; without the right to publish it is submitted for review instead.
| << Previous | Next >> |
|---|---|
| Create LearnDash Quiz | Enroll User in Course |
For more information about the Secure MCP Server for WordPress plugin, explore the following resources:
Product Overview | Pricing | Try for Free | Documentation
If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.