How to make learndash short codes work with cornerstone


I have recently discovered how to customize my Learndash course pages using Cornerstone, which is amazing! However, I’m having trouble with compatibility with their short codes. More specifically, they have the short code [student][/student] that can be used to customize what content to show only to registered students. The short code works within a single text block, but does not work across several blocks or sections in Cornerstone.

I’m wondering if there is another way to do this. For example, can I assign a “student” class to each section I want to appear to students and a “visitor” class to each section I want to appear to those who are not enrolled in the course? I’m not sure what the css would look like to accomplish this.

Thanks in advance for any help you can offer.

Hey @mdmason23,

Thanks for writing in! The shortcode should work in a text element. For best results, you can use the content area instead. So if you want some sections that is only students, then go to X/Pro > Global Blocks. Create a block and then in your course page, you can insert a content area and then the global block shortcode with the [student][/student]. For example, you have a course page and inserted a content area element. On the content area element, you may insert something like this:

[student][cs_gb id=123][/student]

Hope this makes sense.

Thank you! This helps tremendously, but I am noticing some formatting issues when I insert the global block onto my course page. Please see screen shots below of the global block as it appears in the editor and the global block inserted into a course page. The second image contains 2 sections…the inserted global block is the section on the bottom. The section on top is how I want it to look, and is the global block recreated right on the course page using the same settings.
Global Block
Inserted Block

Hello @mdmason23,

The spacing could be coming from the padding or margin of the global block section. To better assist you with your issue, kindly provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

I am doing my testing in the learndash course called “test course”. Currently, there is only one global block. I also did test the global block without the [student][/student] shortcode and the spacing was okay, so it is something about adding that shortcode that messes things up. Website info in a separate secure comment.

Hello @mdmason23,

After thorough investigation, I found out that you cannot use [student][/student] to display a global block. This shortcode does not allow you to insert any custom HTML or custom contents. This shortcode ONLY ALLOW plain text. Usually when you insert [student]sample[/student], the resulting code will be:

<div class="learndash-course-student-message">

This means that any contents in between will be wrapped with a <p></p> tag automatically. This is why when you insert a global block or any custom html, it will result to an issue especially with the spacing because the paragraph <p></p> tag only accepts plain texts. You cannot put div or any other wrapping tags in it.

Hope this explains it briefly.

Curious…because I can use gutenberg blocks and the shortcode works across the blocks no problem, whether it be an image, table, button, or just plain text.

So, is there a way to accomplish what I am trying to do using Cornerstone? Basically, to show different content to a student versus someone who is not enrolled? I would prefer to use the cornerstone editor because it has so many more design features. Registered students do have tags assigned to them, so is it possible to use these to assign a class to each section? Even better yet, since I’ve already done a great amount of work on the global block, can I assign a class or custom css to the global block controlling who it is visible to?

Thanks for your continued help.

Hi @mdmason23,

It works on any builder that stores shortcode in post_content, the problem with storing it in that way is, the longer the content, the slower the builder will load as it will need to parse all content back to builder elements, and vice versa. With that and as part of the cornerstone’s optimization, partial shortcodes are stored on post_content, then the rest of the data is stored in post_meta. This way, data are only called when needed improving the overall loading speed of actual post content, which makes the builder faster.

The downside, if some plugin checks the existence of shortcode from post_content before execution, it will fail. Some developer implements their shortcode outside the standard way of add_shortcode(). Shortcodes added through add_shortcode() will work okay in the cornerstone.

Could you try adding it with classic section, rows, columns, and text element within cornerstone? You can do that by holding your CTRL key (or ⌘ Key on Mac), then the Add Section will become Add Classic Section, then click that.


Then add your classic text element with your learndash shortcode and global blocks.

The classic elements still save its data and shortcode in post_content.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.