Permalinks control how WordPress builds the URLs for content on your site. LearnDash adds its own permalink options, allowing you to customize the URL structure for courses, lessons, topics, and quizzes.
Note: If you’re using custom labels, we recommend you update your LearnDash permalink settings to match your labels.
WARNING: LearnDash works best with a custom permalink structure. Be sure to set this up during the initial configuration, and avoid changing it later, especially after creating course content. Switching permalinks multiple times or using the default “Plain” setting can cause broken links and 404 errors.
Default Permalinks #
By default, your LearnDash content will use the following URLs:
- Courses: https://yoursite.com/courses/course-name/
- Lessons: https://yoursite.com/lessons/lesson-name/
- Topics: https://yoursite.com/topic/topic-name/
- Quizzes: https://yoursite.com/quizzes/quiz-name/
Custom Permalinks #
You can customize the part of the URL that immediately follows https://yoursite.com/.
Let’s say you’re using the following custom labels:
- Courses Tracks
- Lessons Modules
- Topics Lessons
- Quizzes Tests
Let’s also assume you want to use the singular version of each custom label in your URL. For example, instead of yoursite.com/tracks/track-name/, you want yoursite.com/track/track-name/. Here’s how you’d set this up in the permalink settings.
- In the WordPress admin area, go to Settings > Permalinks
- Scroll down to LearnDash Permalinks
- Update the text in each of the first 4 fields to your desired URL structure
- Click Save Changes at the bottom
Category & Tag Permalinks #
If you’re using categories and/or tags for your courses, lessons or topics, you can change those permalinks as well.
- Stay on the same page, Settings > Permalinks
- Scroll down to LearnDash Taxonomy Permalinks
- Update the text in each field to your desired URL structure
- Click Save Changes at the bottom
Nested URLs #
Nested URLs will restructure lesson, topic, and quiz URLs so they are nested hierarchically within the course URL.
Here’s the default topic URL (with nested URLs turned OFF): https://yoursite.com/topic/topic-name/
With nested URLs turned ON, the URL becomes: https://yoursite.com/courses/course-name/lessons/lesson-name/topic/topic-name/
Note: If Shared Course Steps is enabled in Course Settings, nested URLs are required and will be automatically enabled.
Shortening Nested URLs #
NOTE: The following information gets a little technical.
How WordPress URLs work #
Let’s review how WordPress handles rewrite rules for custom post types.
When registering a custom post type, as LearnDash does for courses, lessons, topics, and quizzes, WordPress will create a rewrite rule for the custom post type with a URL structure, using both the post type slug and post slug pair. A rewrite rule is how WordPress handles browser URL requests and matches them to the correct page. This results in default URLs that look like this:
- Courses: https://yoursite.com/courses/course-name/
- Lessons: https://yoursite.com/lessons/lesson-name/
- Topics: https://yoursite.com/topic/topic-name/
- Quizzes: https://yoursite.com/quizzes/quiz-name/
When a browser makes a request to the URL https://yoursite.com/lessons/lesson-name/, WordPress will parse this URL and match it against the rewrite rules and determine that the user is requesting a lesson post type and not a course, post, page, etc. This works the same with taxonomies, where WordPress creates a similar pattern:
- Category: https://yoursite.com/category-slug/category-name/
- Tag: https://yoursite.com/tag-slug/tag-name/
The reason WordPress uses this ‘paired’ post type slug + post slug logic is that post slugs are not unique across all post types. In other words, you are allowed to have both a lesson and a topic with the same slug.
If post slugs were global, then you wouldn’t need the post type slug part of the URL and could just use:
- Lesson: https://yoursite.com/lesson-name/
- Topic: https://yoursite.com/topic-name/
WordPress posts and pages are the exception to this ‘paired’ logic. You will notice that page URLs do not have the /page/ prefix. These built-in post types were in place long before WordPress added the changes to support custom post types, so the rewrite logic is handled differently.
How Nested URLs Work #
When enabling the Nested URLs feature in LearnDash, we had to keep this post type slug + post slug ‘paired’ logic. This is why the URL for a topic becomes: https://yoursite.com/courses/course-name/lessons/lesson-name/topic/topic-name/
The solution LearnDash uses for Nested URLs is one we consider will work across all customer sites. By using the post type slug + post slug ‘paired’ logic, and following recommended WordPress guidelines, we can always match the course elements during a URL request.
Custom Rewrite Rules #
It is still possible to create your own custom rewrite rules using standard WordPress hooks. You would hook into the generate_rewrite_rules action (documentation). This hook lets you add your own custom rewrite pattern to replace or supersede the default rules.
For example, you could add a pattern to create shortened topic URLs by removing the lesson and topic post type slugs, resulting in this: https://yoursite.com/courses/course-name/lesson-name/topic-name/
This assumes a lesson will ALWAYS follow a course post slug (and it does), and a topic will ALWAYS follow a lesson post slug (and it does). You could still encounter a problem with quizzes, since a quiz can be standalone or attached to the end of a course, lesson, or topic.
- Standalone Quiz: https://yoursite.com/quizzes/quiz-name/
- Course Quiz: https://yoursite.com/courses/course-name/quiz-name/
- Lesson Quiz: https://yoursite.com/courses/course-name/lesson-name/quiz-name/
- Topic Quiz: https://yoursite.com/courses/course-name/lesson-name/topic-name/quiz-name/
Since WordPress does not consider post slugs to be unique across all post types, there is no way to formulate a rewrite rule pattern to pick out the quiz in the URL without the post type slug ‘paired’ logic.