LLMS_Course::get_lessons_count()
Retrieve the number of course’s lessons.
Description Description
This is less expensive than counting the result of LLMS_Course::get_lessons(), and should be preferred when you only need to count the number of lessons of a course.
Return Return
(int)
Source Source
File: includes/models/model.llms.course.php
public function get_lessons_count() {
$query = new WP_Query(
array(
'meta_key' => '_llms_parent_course',
'meta_value' => $this->get( 'id' ),
'post_type' => 'lesson',
'posts_per_page' => -1,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'fields' => 'ids',
'orderby' => 'ID',
'order' => 'ASC',
)
);
return $query->post_count;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.1.0 | Introduced. |