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.
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
By default, your LearnDash content will use the following URLs:
You can customize the part of the URL that immediately follows
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
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 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):
With nested URLs turned ON, the URL becomes:
Shortening Nested URLs
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:
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:
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:
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:
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:
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:
- Course Quiz:
- Lesson Quiz:
- Topic Quiz:
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.