Customizing LearnDash 3.0 templates

If you’ve ever done any customization of the LearnDash template files, you’ll find that the process has changed with the release of LearnDash 3.0.

For example, in LearnDash 2.X, to customize a lesson page you would copy lesson.php from the plugin directory to your child theme, edit it, and your changes will show up on the site. But take a look at the legacy lesson.php template as compared to the 3.0 version:

The legacy lesson.php file on the left, and the 3.0 version on the right.

So it’s hard to see in the small screenshots, but the new 3.0 lesson.php file has almost no HTML code in it. There’s really not much to customize if you’re wanting to modify the layout. You’ll need to locate the file that has the appropriate code you want to modify, and depending on what you are changing, you may have to edit more than one php file.

The trick is finding out which file has the code to change. What I did was download the entire 3.0 theme directory from the plugin: /wp-content/plugins/sfwd-lms/themes/ld30.

Then, I located the section of the code I wanted to modify by viewing the source code of a rendered page.

In my case, I wanted to add some custom text below the breadcrumb on my topic pages. The breadcrumb uses the CSS class “ld-topic-status”, so I searched that entire ld30 directory for that class (just use FileSeek or something similar). That led me to the file /wp-content/plugins/sfwd-lms/themes/ld30/templates/modules/infobar.php.

 To make it even more confusing, topic and lesson templates don’t use the same naming structure – to do the same thing to a lesson, I have to edit /wp-content/plugins/sfwd-lms/themes/ld30/templates/modules/tabs.php.

Once you’ve edited the file to your liking, you’ll upload it to your child theme, with a slightly different directory structure.

 In your child theme, make a folder structure like this: /wp-content/themes/xxx-child/learndash/ld30

Then, you’ll create subfolders without the templates folder. In other words, if you’re overriding the file:
     /wp-content/plugins/sfwd-lms/themes/ld30/templates/modules/infobar.php
then the file in the child theme will be:
     
/wp-content/themes/xxx-child/learndash/ld30/modules/infobar.php

Just upload the new file to your child theme, in the correct folder.

One more gotcha – you can’t tell what templates have been overridden by checking out the support tab of the LearnDash Settings page:

If you override the actual lesson.php file, it will turn red on this page. But you’ll find that the majority of the files you need to work with aren’t actually listed here.

1 thought on “Customizing LearnDash 3.0 templates”

  1. Thank you for this. I’d worked with custom templates in < 3.0, but this was helpful for seeing the structure change. The code looks a heck of a lot cleaner but is definitely more abstracted.

    Cheers,
    Carrie

Leave a Comment

Your email address will not be published. Required fields are marked *