Adding custom content to LearnDash courses using shortcodes

Written by Andy Jack

27 July 2021

As a training provider, your clients are important to you and you want to be able to customise courses for each organisation you work with. But how can you do this without replicating each course and having to then manage several courses that are very similar?

With the Business-to-Business toolkit for LearnDash we’ve solved this problem for you! You can very easily use shortcodes to add specific content for organisations into the course content. So for example, if a client wants you to signpost their employees to a specific internal resource or person within their organisation about a certain topic, you can add this without having to replicate entire lessons, topics, or courses.

Find out more in the walkthrough video below:


Transcript:

[Mark] Hi, it’s Mark from Training Spark here, and this is video seven of a series of videos where we’re looking at the Business-to-Business Toolkit.

In this video, we’re going to look at ways you can add tailored content to various courses and other pages on your site. And that means you can tailor content, ensure specific content to your organizations. So over the past series of videos, we’ve created an organization called Home Tech and added groups to it, added ways for users to enroll into those groups and access the course materials.

And what we’re going to do here is show you ways you can add content to pages that would only ever appear to members of the Home Tech group. So I’m on a page here. One of the course is called healthy eating for healthy life, and I can see that this has a page called drinking fluids for a healthy day. What I’m able to do is show some content on this page only to members of Home Tech, but not to any of the other groups, or any other organizations. And an example of when you might use this is if you wanted to signpost members of an organization to their own HR department. So you could put specific details about that, but it just gives you flexibility to do that without having to create a brand new course specific to Home Tech, for example. So you’re not going to double up on bits of content by creating more courses than you need. Within the same course, we can add what’s called a shortcode to allow us to show specific bits of content to specific organizations.

So as I mentioned, these are done via something called the shortcode. And shortcodes are a feature of WordPress that allow you to add little snippets of code and carry out complex features with very little effort. You just have to add in a bit of code to a page and it will carry out certain functionality. So we’ll get that shortcode by going back to the dashboard of your site, then heading to Business-to-Business Toolkit, and then the organizations.

And what we’re going to do is click back into our Home Tech organization here. At the very bottom of the page, we have this section here called display custom content for this organization. And it says, use the following shortcode to display content specific to members of the organization, and users outside of the organization will not see any content we use within the shortcode. And this is what the shortcode looks like. So typically these have these square brackets and something that happens between them.

What I’m going to do is just click this copy to clipboard action here, and it says shortcode copied. And we were looking at the drinking fluids for a healthy day lesson. So I’m going to go to LearnDash LMS and then lessons. I’m going to open the drinking fluid for a healthy day lesson here. And I’m just going to make some changes to it to add this shortcode that we’ve copied. So this is what the page looks like. Perhaps at the very top of the page here, I could drop down a couple of lines here and then just paste in the shortcode that I created there.

And if you’re using the Gutenberg editor, it’ll look something like this, but equally this can be used on the classic editor. And what we can do is split this across into two, a few lines just to show you what we can see here. So at the top we’ve got the top of the shortcode, which is B2B show for company ID equals this. And that is the ID of the organization that we’re working on here. And then we see the closing part of it here. And anything between here is the content that we can show this to this learner of the organization. And you can see here, it’s written as some content that is only visible to the learners in the Home Tech organization.

I’m just going to delete that bit here and say, we have, cause this is about drinking. Vending machines on floors three and five with a variety of drinks. So this is a line that obviously is related to Home Tech, but anyone else on any other organization who comes to their drinking fluids for a healthy day, it wouldn’t apply to them because they don’t have vending machines on floors three and five, only Home Tech do.

So if I was to click update now and go back to the course as a Home Tech user and then refresh it, we can see a line here, which says we have vending machines on floors three and five with a variety of drinks. So this is some content that will only appear on this course for members of Home Tech. And just to show you how this appears to everyone else. If I was to go back in, perhaps just using my admin account back to the same course, by going to all courses, healthy eating for a healthy life, and then the drinking fluids for a healthy day course. If I scroll down, we’ll see that I don’t see that line. So that line is only available to members of the Home Tech group, and isn’t shown to any other organizations or any other users on the system.

So that’s how we can add some content specific to an organization, and that could include texts as well as anything really. So anything you can put between those two lines, be it an image or a video or something like that can be specific to that organization.

0 Comments

Submit a Comment

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

Other blog posts you may be interested in…