1

我希望使用适用于 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

谢谢。

4

1 回答 1

1

可能为时已晚,但在搜索了几个小时的相同解决方案后,我将答案留在这里。

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();
    }
}

?>

我希望它有帮助!

于 2020-03-31T19:20:30.917 回答