我希望使用适用于WordPress的LearnPress LMS插件查询与特定“课程”相关的“课程”。
例如,如果我的“课程” ID是“ 123”,我如何获得相关“课程”的列表?
请参阅支持提交(无帮助): https://thimpress.com/forums/topic/how-do-i-get-a-list-of-lesson-ids-from-a-course-id/#post-460461
谢谢。
答案 0 :(得分:0)
可能已经晚了,但在搜索相同的解决方案几个小时后,我在这里留下了答案。
LearnPress版本:3.2.6.7
WordPress版本:5.3.2
<?php
// Get the course instance.
$course = learn_press_get_course( $course_id );
// Get the curriculum of the course.
$curriculum = $course->get_curriculum();
// Iterate over the curriculum sections.
foreach ( $curriculum as $section ) {
// Get the lessons associated with the section.
$lessons = $section->get_items();
// Iterate over each lesson.
foreach ( $lessons as $lesson ) {
// Now you can work with each lesson, for example:
// Get the lesson ID.
$lesson_id = $lesson->get_id();
}
}
?>
希望对您有帮助!