1

I'm hoping to query ‘Lessons’ associated with a particular 'Course' using the LearnPress LMS plugin for WordPress.

So for example, if my ‘Course’ ID is “123”, how can I get a list of the related 'Lessons'?

See support submission (was no help): https://thimpress.com/forums/topic/how-do-i-get-a-list-of-lesson-ids-from-a-course-id/#post-460461

Thanks.

Kalamarico
  • 5,466
  • 22
  • 53
  • 70
Elliott
  • 11
  • 5

1 Answers1

1

It may be late but I leave the answer here after searching for the same solution for several hours.

LearnPress version: 3.2.6.7

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

?>

I hope it helps!