Permalinks determine how WordPress choses the URLs to use for different types of content on your site. LearnDash provides additional permalink settings to let you customize how your URLs are structured for courses, lessons, topics & quizzes.
If you』re using custom labels, we recommend you update your LearnDash permalink settings to match your labels.
WARNING
If you』re going to customize your LearnDash permalinks, we recommend you do it only once, at the beginning of your setup. Changing your permalinks multiple times, or after you』ve already created a bunch of content, could lead to broken links & 404 errors.
Table of Contents [show]1 Default Permalinks2 Custom Permalinks2.1 Category & Tag Permalinks3 Nested URLs3.1 Shortening Nested URLs3.1.1 How WordPress URLs work3.1.2 How Nested URLs Work3.1.3 Custom Rewrite Rules3.2 Was this article helpful to you?
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, navigate 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 & 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 is 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—like LearnDash does for courses, lessons, topics & quizzes—WordPress will create a rewrite rule for the custom post type with a URL structure using both the post type slug & post slug pair. A rewrite rule is how WordPress handles URL requests from the browser 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 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 because 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 used by LearnDash 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.
Was this article helpful to you?
Yes
No