How To Display Relevant Courses / Modules / Lessons on the Sidebar

Namaste! LMS provides handy shortcodes for displaying current course’s lessons and modules, and module’s lessons. You can even pass course or module ID to the shortcodes to display the modules or lessons that belong to another course / module. So far, so good, but how do you display this in the sidebar?

Installing the Widget Context Plugin

There is an excellent free plugin called Widget Context that takes care to display widgets only on selected post types. Install it and activate it. You’ll most likely want to display different widgets on the different types of pages. Also, you’ll probably not want to display these widgets on your regular non-LMS pages (contact & about pages, blog posts, etc).

Course Pages

Normally what you’ll want to display on a course page is the list of lessons in the course and/or (if you use modules) a list of modules in it. This can’t be easier:

  • Create a text widget and place it in the sidebar.
  • Insert the shortcode
      or
        in it depending on what you want to show (you can create one widget for each if you prefer)
      • Select that this widget will be shown only on “Courses” pages (or maybe you want to use the same widget on your modules & lessons page – no problem, Namaste! LMS shortcodes are smart enough to figure out the lessons related to the course regardless if you are on the course page itself, or a module / lesson belonging to that course).
      • Here’s an example:

      You can see how this works in our demo.

      Module Pages

      On module pages you’ll probably want to show lessons in this module and modules in this course. Similar to the above:

      • For “lessons in this module” use
          shortcode and place it in a widget that is shown only on “Module” pages.
        • For “modules in this course” use
            shortcode and place it in a widget that is shown only on “Module” pages.

          It’s probably not wise to include all lessons in the course but if you want to do it, just enable the widget from the previous example on “Module” pages as well.

          Lesson Pages

          On lesson pages you may want to show all lessons in this course, or if you use modules also the modules in this course, the lessons in this module.

          • In our first example displaying all lessons in this course is already done and the same widget is enabled for “Lessons” posts. If you want to use different widget (or don’t show lessons on course pages) just use the shortcode
              without ID parameter (so just use it as you see it here) again and enable the widget for lessons.
            • To show modules in this course use
                in such widget.
              • To show lessons in the same module use
                  without using ID parameter and enable the widget for Lessons posts. You can even use the same widget on module pages.

                That’s it, quite simple. If you think other existing shortcode should have course / lesson / module relevant behavior let us know.

                Do not use any of the shortcodes without ID attribute on archives or search results pages because the system won’t know which is the current post they relate to. Using the shortcodes without ID makes sense only on pages that show a single course, lesson or module.

                Leave a Reply

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