Common changes with a few lines of code (Recipes)
Reign LearnDash Addon overviewPremiumGet Reign LearnDash Addon →
Also called: code snippets, functions.php recipes, child theme examples, customise courses with code, LearnDash add-on hooks examples
Each recipe below makes one change that site owners often ask for. Copy the snippet, paste it into your child theme, and save. Every snippet was tested with Reign LearnDash Addon 5.2.0, LearnDash 5.2, Reign 8.1.0 and the official Reign child theme.
Before you start
Section titled “Before you start”- Install and activate the Reign child theme. Changes in the parent theme are lost when Reign updates.
- Open the child theme’s
functions.php. Paste each snippet at the very end of the file. - Edit files through your host’s file manager or SFTP. If a snippet has a typo, the site can show an error. You can then fix the file the same way.
Try each change on a staging copy first if your site is busy.
Show the Courses tab only to the member
Section titled “Show the Courses tab only to the member”Each member profile has a Courses tab. By default other people see it too, when the member is enrolled in a course or teaches one. This snippet shows the tab only to the member and to site admins.
add_filter( 'reign_ld_courses_tab_visible', function ( $visible, $profile_user_id, $viewer_id ) { if ( $viewer_id !== $profile_user_id && ! current_user_can( 'manage_options' ) ) { return false; } return $visible;}, 10, 3 );The filter hides the menu item and the page together, so nobody lands on an empty tab. It needs BuddyPress with the Groups component on.
You’ll know it worked when a logged-out visitor opens a member profile and sees no Courses tab. The member still sees it on their own profile.
Use a different course page layout for one category
Section titled “Use a different course page layout for one category”The add-on has four course page layouts: reign, classic, spotlight and academy. You pick one for the whole site in the settings, or one per course. This snippet gives every course in the “Design” category the Academy layout.
add_filter( 'reign_ld_course_template', function ( $template, $course_id ) { if ( has_term( 'design', 'ld_course_category', $course_id ) ) { return 'academy'; } return $template;}, 10, 2 );Change design to the slug of your course category. You find the slug on the category’s edit screen.
You’ll know it worked when a course in that category opens with the Academy layout. The page <body> then has the class rld-course--academy.
Hide the short description on some course cards
Section titled “Hide the short description on some course cards”On the course list, each card can show a short description (the excerpt). This snippet hides it on cards for courses in the “Marketing” category. Other cards keep it.
add_filter( 'reign_learndash_course_card_parts', function ( $parts, $course_id ) { if ( has_term( 'marketing', 'ld_course_category', $course_id ) ) { $parts['excerpt'] = false; } return $parts;}, 20, 2 );This filter belongs to the Reign theme, and it draws the cards for the default Reign course list layout. Keep the 20: the add-on fills the same list at 10 from its Cards show setting, and yours must run after it. The other parts you can turn off are badge, progress, meta (the lesson count) and instructor.
For the Classic, Soft and Catalog layouts, the add-on draws the card itself. Use reign_ld_card_data there. See Hooks and filters.
You’ll know it worked when the cards for marketing courses show no description on the Courses page.
Change one template: show related courses as a simple list
Section titled “Change one template: show related courses as a simple list”The course page ends with a “Related courses” section that shows full course cards. This override turns it into a plain list of course names. Use the same steps for any file in the add-on’s templates/ folder.
-
Copy
reign-learndash-addon/templates/course/related.php. -
Paste it into your child theme at
reign-child-theme/learndash/reign/course/related.php. Create thelearndash,reignandcoursefolders if they are missing. -
In your copy, find this line.
<li><?php Reign_LD_Grid::course_card( Reign_LD_Course_Data::card( $course_id ), (array) Reign_LD_Settings::get( 'card_fields' ), $rld_template ); ?></li> -
Replace it with this line.
<li><a href="/reign-family/reign-learndash-addon/developer-guide/</?php echo esc_url( get_permalink( $course_id ) ); ?>"><?php echo esc_html( get_the_title( $course_id ) ); ?></a></li> -
Save the file.
You’ll know it worked when the Related courses section on a course page shows course names as links, with no images or buttons.
Keep the @version 5.2.0 line in your copy. After an add-on update, the settings screen lists your copy under Outdated template overrides if the original changed. Then compare your copy with the new file. See Template overrides for every file you can override.
Good to know
Section titled “Good to know”My snippet broke the site. What do I do?
Section titled “My snippet broke the site. What do I do?”Open functions.php again through your host’s file manager or SFTP. Remove the snippet you just added and save. The site comes back straight away.
Can I use a code snippets plugin instead?
Section titled “Can I use a code snippets plugin instead?”Yes. The PHP snippets work the same in a snippets plugin. The template recipe needs the child theme, because it is a file.
Where do I find more hooks?
Section titled “Where do I find more hooks?”Every hook the add-on offers is in Hooks and filters.

