Since the introduction of the new [namaste-breadcrumb] shortcode in Namaste! LMS it’s now easy to add a breadcrumb navigation that lets you see your position in the learning process. It looks like this:
Course link >> Module link >> Lesson
Or if you don’t use modules:
Course link >> Lesson.
Simple. You can just drop the shortcode inside every lesson and/or module and you’ll get the navigation.
But how to add it to your theme?
There are two ways: the easiest is to get the Namaste! Premium theme which has this option built in:
The other method is manual. It’s also not too hard, so let me explain how to do it. You’ll need a very basic understanding of HTML, editing PHP files and a text editor like Notepad++
- Download your theme locally.
- Open the file single.php. Use “Save as” and save it as single-namaste_lesson.php
- In that file find the following line:
get_template_part( 'template-parts/content', get_post_format() );
- Replace it with this:
get_template_part( 'template-parts/content-lessons', get_post_format() );
- Open the file template-parts/content.php. Use “Save as” and save it as template-parts/content-lessons.php
- Go right before the following line that wraps the article:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
And add the following code:
<?php echo do_shortcode('[namaste-breadcrumb]');?>
Feel free to wrap it in a div or another element if you like.
That’s it. If you use modules, you need to repeat the steps but save the files as single-namaste_module.php and template-parts/content-modules.php. Also the line in step 4 will be like this:
get_template_part( 'template-parts/content-modules', get_post_format() );
Don’t forget that the shortcode allows you to use custom separator so you can use it like this:
<?php echo do_shortcode('[namaste-breadcrumb separator="/"]');?>