Select Page
Topic Progress:
Course Status: N/A

Adding proper breadcrumb trails to Learndash can be a bit tricky.

This is because you have categories that are topics and lessons.

Its not that simple to understand without using learndash.

In Learndash your top level item is a Course.

Second Level is a Lesson.

Third Level is a Topic.

This means if you are creating a breadcrumb, ideally you want it to show Course > Lesson > Topic

The Code

This code gist will add in the breadcrumb path you see on the Divi Framework site.

This is very useful in letting your customers know where to go. To use this code past it as is into your functions.php file in your Child Theme for your WordPress website.

This will work on any site using the breadcrumbs from Yoast SEO.

Code Review

Lets review the code line by line.

The first line calls our function base on a hook provided by Yoast SEO.

This hook calls out function found on line 3.

We set the Global Post item to be present inside the scope of the function.

Next we check if we are in a lesson. If we are we get the details of the parent course and update the array that stored the breadcrumb path. This will update the breadcrumbs.

If we are not in a lesson, we then check if we are in a topic and perform a similar function, making sure we check our parent Lesson and Course, update the Array and add it to the Yoast SEO Breadcrumb object.

It took me a LONG time to work out exactly how to get this right but this has been reliable for over a year now.

Hope you enjoy it and feel free to let me know if you need further instructions.

 

 

Divi Framework - build anything with Divi to create your online business.

30 day money back guarantee

Safe & Secure online payment

Support team & documentation