This document provides guidance on how to use the [ld_course_list] shortcode with an author ID parameter to filter and display courses created by specific instructors or authors.
Shortcode Usage
You can use the [ld_course_list] shortcode with the course_instid parameter to filter courses by author. The author ID corresponds to the WordPress user ID of the instructor or course creator.
Example Usage
[ld_course_list course_instid="4"]
Description
- course_instid: Accepts a single author ID. It will filter and display courses only from the specified author.
Example Output
The shortcode [ld_course_list course_instid="4"] will list all courses created by the author with ID 4.
How to Find Author ID
- Go to the WordPress Dashboard.
- Navigate to Users > All Users.
- Click on the desired author or instructor.
- In the URL of the user profile page, you will see
user_id=followed by the user’s ID. That is the author ID.
Example URL:
https://yoursite.com/wp-admin/user-edit.php?user_id=4
Here, the author ID is 4.
Troubleshooting
- Courses not showing?
- Ensure the provided author ID corresponds to a valid instructor.
- Confirm that the author has at least one published course.
- Multiple Parameters Not Working?
- Make sure you are not combining conflicting filters (e.g., filtering by both
course_instidand unrelated categories).
- Make sure you are not combining conflicting filters (e.g., filtering by both
- Verify Query Variables:
- Use debugging to ensure the author ID is passed correctly by inspecting the query variables. You can use the following code for debugging:
error_log(print_r($query->query_vars, true));
Advanced Usage with URL Parameter
You can also pass the author filter through the URL like so:
https://yoursite.com/courses/?course_instid=4
This will automatically filter and display the courses by the specified author without needing to use the shortcode.
Conclusion
The course_instid parameter for [ld_course_list] provides an easy way to filter courses by author. This feature can be useful when displaying instructor-specific courses on the frontend of your site.
