Snippet: Add a Custom Message Above the LearnDash Course Content List
Print a welcome note, instructions or a status-aware message right above the lesson list on every course page using the learndash-course-content-list-before action, styled with LearnDash alert classes.

The course content list is the part of a LearnDash course page learners actually read: the expandable list of lessons, topics and quizzes under the Course Content heading. It is also the natural place for a short message that applies to the whole course, such as "work through the lessons in order", "the final quiz opens on Friday" or "you have completed this course, download your certificate above". Editing the course description puts the text in the wrong place, and editing the template means maintaining a copy. The ld30 template fires an action immediately before the list, and this snippet uses it.
The hook
In themes/ld30/templates/course.php the content list is wrapped by two actions, learndash-course-content-list-before and learndash-course-content-list-after, both called with the course ID and the user ID. They fire only when the course has steps to list, which is what you want for a message about the steps. The same template also offers learndash-course-heading-before and learndash-course-heading-after around the Course Content heading itself, and learndash-course-before at the very top of the course content with the post ID as an extra first argument, for messages that should appear above the description instead.
A fixed message
<?php
add_action(
'learndash-course-content-list-before',
function ( $course_id, $user_id ) {
echo '<div class="ld-alert ld-alert-info wwc-course-note">'
. esc_html__( 'Work through the lessons in order. Each one opens when the previous lesson is marked complete.', 'wwc' )
. '</div>';
},
10,
2
);
The ld-alert and ld-alert-info classes come from the ld30 stylesheet, so the message matches the warnings LearnDash prints itself; ld-alert-warning and ld-alert-success are the other two variants. Add your own class as well so you can style or hide the note without affecting LearnDash's alerts.
A message per course
Course-specific text belongs in course data rather than code. The simplest store is a post meta field that editors can fill in through a custom field or a meta box:
<?php
add_action(
'learndash-course-content-list-before',
function ( $course_id, $user_id ) {
$note = get_post_meta( $course_id, 'wwc_course_note', true );
if ( '' === trim( (string) $note ) ) {
return;
}
echo '<div class="ld-alert ld-alert-info wwc-course-note">'
. wp_kses_post( wpautop( $note ) )
. '</div>';
},
10,
2
);
wp_kses_post() allows the same HTML as a post body and strips anything else, so an editor can add a link or bold text without opening a scripting hole.
A status-aware message
Because the hook receives the user ID, the message can react to the learner's position in the course. learndash_course_status( $course_id, $user_id, true ) returns the slug not_started, in_progress or completed:
<?php
add_action(
'learndash-course-content-list-before',
function ( $course_id, $user_id ) {
if ( empty( $user_id ) || ! sfwd_lms_has_access( $course_id, $user_id ) ) {
return;
}
$status = learndash_course_status( $course_id, $user_id, true );
$messages = array(
'not_started' => __( 'Welcome. Start with the first lesson below; it takes about ten minutes.', 'wwc' ),
'in_progress' => __( 'Pick up where you left off. Your next lesson is marked with an arrow.', 'wwc' ),
'completed' => __( 'You have completed this course. Your certificate is available at the top of the page.', 'wwc' ),
);
if ( ! isset( $messages[ $status ] ) ) {
return;
}
$class = ( 'completed' === $status ) ? 'ld-alert-success' : 'ld-alert-info';
printf(
'<div class="ld-alert %1$s wwc-course-note">%2$s</div>',
esc_attr( $class ),
esc_html( $messages[ $status ] )
);
},
10,
2
);
The access check keeps the message off the page for visitors who are not enrolled, who see the enrollment box instead and do not need lesson instructions.
A message per group
Corporate sites often run one course for several client groups, each with its own deadline or contact. Because the hook receives the user ID, the note can come from the learner's group rather than the course. learndash_get_users_group_ids( $user_id ) returns the groups the learner belongs to; pick the first one that has a note stored in group post meta, for example wwc_group_note, and print it the same way as the per-course version. Where a learner is in several groups, decide the order deliberately, most recently joined or alphabetical, and document it for the people who write the notes. Group leaders can edit group meta if you expose it in a meta box on the group screen, which keeps the text with the people who own the relationship.
Translation
Strings in the snippets use a wwc text domain so they can be translated with the rest of your customisations; load the domain in your plugin header or with load_plugin_textdomain(). Notes stored in post meta are not covered by translation files. On a multilingual site, store one note per language in separate meta keys, or let the translation plugin translate the course post and store the note on each translated course, which is the usual pattern for WPML and Polylang because each translation is its own post ID.
Placement choices
- Above the heading with
learndash-course-heading-beforeputs the note above "Course Content" and the expand-all control. Use it for text that is about the course as a whole. - Between heading and list, as in the snippets above, reads as an instruction for the list. This is the usual choice.
- After the list with
learndash-course-content-list-aftersuits a "need help?" prompt or a link to the course forum.
Focus Mode and other templates
These actions live in the course template, so they do not fire inside Focus Mode lesson pages, which have their own hooks listed in our Focus Mode header snippet. A theme that overrides course.php may have removed the actions; check the override before assuming the snippet is broken, as explained in the template system guide. Keep the snippet in a child theme or mu-plugin per our update-safe customisation guide.
Testing
- View a course with lessons as a visitor: no note, enrollment box shown.
- Enrol a test learner and view: the not-started note appears between the heading and the list.
- Complete one lesson, then the whole course, and confirm the text changes each time.
- View a course with no steps: the hook does not fire and nothing prints, which is expected.
When to get help
A note is a quick win. Messages driven by cohort dates, group membership or a CRM field are a small plugin, and our LearnDash services team builds those regularly; a LearnDash developer can also add the editor-side meta box so course authors maintain the text themselves.
Frequently asked questions
Which hook adds content above the LearnDash lesson list?
learndash-course-content-list-before, fired in the ld30 course template with the course ID and user ID, immediately before the list of lessons.
Why does my message not show on a course without lessons?
The content list, and therefore the hook, is only rendered when the course has steps. Use learndash-course-before for a message that must always appear.
Can the message differ per learner?
Yes. The hook receives the user ID, so you can branch on learndash_course_status(), group membership or any user meta.
Does this work in Focus Mode?
Not on lesson pages, which use the focus template. The course page itself is not rendered in Focus Mode, so the message appears there as usual.
Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.
