我希望使用WordPress的LearnPress LMS插件来查询与特定“课程”相关的“课程”。
例如,如果我的‘Course’ID是“123”,我如何获得相关'Lessons‘的列表?
查看支持提交(was没有帮助):https://thimpress.com/forums/topic/how-do-i-get-a-list-of-lesson-ids-from-a-course-id/#post-460461
谢谢。
发布于 2020-04-01 03:20:31
可能会很晚,但我在寻找相同的解决方案几个小时后,将答案留在了这里。
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();
}
}
?>我希望它能有所帮助!
https://stackoverflow.com/questions/57107279
复制相似问题