Hierarchical Breadcrumb Navigation in Namaste! LMS

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:

Breadcrumb navigation in Namaste! LMS Theme

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++

  1. Download your theme locally.
  2. Open the file single.php. Use “Save as” and save it as single-namaste_lesson.php
  3. In that file find the following line:
    get_template_part( 'template-parts/content', get_post_format() );
  4. Replace it with this:
    get_template_part( 'template-parts/content-lessons', get_post_format() );
  5. Open the file template-parts/content.php. Use “Save as” and save it as template-parts/content-lessons.php
  6. 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="/"]');?>

 


Leave a Reply

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