Snippet: Add the Lesson Author and Date Under the LearnDash Lesson Title
Show who wrote a lesson and when it was last updated under the title, in both the normal theme layout and Focus Mode, using learndash-lesson-before and learndash-focus-content-content-before without a template override.

Blog posts carry a byline; LearnDash lessons do not. For compliance training, where learners need to know a procedure was updated this year, and for instructor-led sites, where the author's name builds trust, a line under the lesson title saying who wrote it and when it was last revised is worth adding. Most themes drop their byline for the lesson post type, and Focus Mode has no byline at all. This snippet prints one in both layouts with two action hooks from LearnDash 4.18.0.1, verified in the ld30 templates.
Where the title is printed
In the normal layout your theme prints the lesson title, and LearnDash's lesson template is injected as the post content. That template, themes/ld30/templates/lesson.php, starts with do_action( 'learndash-lesson-before', get_the_ID(), $course_id, $user_id ), so output from that hook lands at the top of the content, directly under the theme's title.
In Focus Mode, themes/ld30/templates/focus/index.php prints the title itself inside div.ld-focus-content, with learndash-focus-content-title-before fired before the h1 and learndash-focus-content-content-before fired between the h1 and the content. Both receive the course ID and user ID. The lesson template still runs inside the content, so learndash-lesson-before fires in Focus Mode too; if you hook both, you must prevent the line printing twice.
The snippet
<?php
/**
* Build the byline for a lesson or topic.
*/
function wwc_lesson_byline( $post_id ) {
$post = get_post( $post_id );
if ( ! $post ) {
return '';
}
$author = get_the_author_meta( 'display_name', $post->post_author );
$updated = get_the_modified_date( get_option( 'date_format' ), $post );
return sprintf(
'<p class="wwc-lesson-byline">%1$s <span class="wwc-byline-author">%2$s</span> <span class="wwc-byline-sep">·</span> %3$s <time datetime="%4$s">%5$s</time></p>',
esc_html__( 'By', 'wwc' ),
esc_html( $author ),
esc_html__( 'Updated', 'wwc' ),
esc_attr( get_the_modified_date( 'c', $post ) ),
esc_html( $updated )
);
}
/**
* Focus Mode: under the h1, before the content.
*/
add_action(
'learndash-focus-content-content-before',
function ( $course_id, $user_id ) {
echo wwc_lesson_byline( get_the_ID() ); // Escaped in wwc_lesson_byline().
},
10,
2
);
/**
* Normal layout: top of the lesson content. Skip when Focus Mode handled it.
*/
add_action(
'learndash-lesson-before',
function ( $lesson_id, $course_id, $user_id ) {
if ( wwc_is_focus_mode_active() ) {
return;
}
echo wwc_lesson_byline( $lesson_id ); // Escaped in wwc_lesson_byline().
},
10,
3
);
/**
* Whether the current request renders the Focus Mode template.
*/
function wwc_is_focus_mode_active() {
return 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Theme_LD30', 'focus_mode_enabled' );
}
The Focus Mode check reads the same setting the plugin uses to decide whether to load the focus template, so when Focus Mode is on the first hook prints and the second stays quiet, and when it is off the reverse happens. The byline uses the modified date rather than the published date because learners care when the content last changed.
Topics
Topics share the Focus Mode template, so the first hook already covers them. For the normal layout add the same callback to learndash-topic-before, which topic.php fires with the topic ID, course ID and user ID.
Styling
.wwc-lesson-byline {
margin: 0 0 1.5rem;
font-size: 0.875rem;
color: #666;
}
.ld-focus .ld-focus-content .wwc-lesson-byline {
margin-top: -0.5rem;
}
Focus Mode adds its own spacing under the heading, so the negative top margin tightens the gap. Adjust the colour to your theme's muted text token and check contrast.
Keeping the date honest
The modified date changes whenever the post is saved, including saves that only touch LearnDash settings such as drip timing. If that makes the date meaningless, store a reviewed date in post meta and print it instead; a single custom field named wwc_reviewed_on, read with get_post_meta() and formatted with wp_date(), gives editors control over what "Updated" means. Our course Dashboard tab guide describes the other per-course dates LearnDash tracks if you need them for context.
Author display
LearnDash lessons are authored by whoever created them, which on many sites is an administrator account rather than the subject expert. Either change the author on the lesson, which the block editor allows for users with the right capability, or map authors to display names in the byline function. If instructors are group leaders, the author selector is only available to them when the Group Leader User setting for it is on, as described in our group leader role guide.
Adding a reviewer and a version
Regulated training often needs more than author and date: the name of the person who approved the content and a version label. Both fit the same line. Store wwc_reviewer and wwc_version as post meta, read them in the byline function with get_post_meta(), and append them when present, escaping each with esc_html(). Keep the order consistent, author, reviewer, version, updated, so learners learn to scan it. A short meta box on the lesson edit screen, registered with add_meta_box() for the sfwd-lessons and sfwd-topic post types, lets editors fill the fields without touching code; remember to check current_user_can( 'edit_post', $post_id ) and a nonce in the save handler.
Performance
The byline reads the post object, which is already loaded, and the author's display name, which WordPress caches per request. Post meta for the lesson is loaded in one query when the post is fetched, so extra fields cost nothing further. There is no reason to cache the output.
Markup for search engines
The time element with a machine-readable datetime attribute is enough for crawlers to pick up the modified date. If your SEO plugin outputs Article structured data for lessons, it already includes dateModified and the author from the post, so the visible byline and the structured data agree without extra work. Public lessons on open courses benefit most; lessons behind enrollment are not indexed anyway.
Testing
- With Focus Mode off, open a lesson: the byline sits under the theme's title, above the LearnDash infobar.
- Turn Focus Mode on and reload: one byline, directly under the
h1. - Edit the lesson text and save: the date updates. Change the author and confirm the name follows.
- Check a topic in both modes.
When to get help
A byline is a quick task. Reviewed-on workflows, author profile cards with photos and credentials, or a change log per lesson are small plugin projects that our LearnDash services team builds, and a LearnDash developer can add the editor fields so content owners maintain the data themselves.
Frequently asked questions
Which hook fires under the title in LearnDash Focus Mode?
learndash-focus-content-content-before, fired in the focus index template between the h1 and the lesson content, with the course ID and user ID.
Why would the byline print twice?
Because the lesson template, and its learndash-lesson-before hook, also runs inside Focus Mode. The snippet checks the Focus Mode setting and prints from one hook only.
Should I show the published or the modified date?
The modified date tells learners when content last changed, which matters for compliance. Use a custom reviewed-on field if routine saves make it misleading.
Does this work for topics and quizzes?
Topics yes, through the same Focus hook and learndash-topic-before. Quizzes use a different template and are usually left without a byline.
Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.
