LLMS_Course::get_sections( string $return = 'sections' )

Get course sections


Parameters Parameters

$return

(string) (Optional) Type of return [ids|posts|sections]. Default is 'sections'.

Default value: 'sections'


Top ↑

Return Return

(int[]|WP_Post[]|LLMS_Section[]) The type depends on value of $return.


Top ↑

Source Source

File: includes/models/model.llms.course.php

	public function get_sections( $return = 'sections' ) {

		$q = new WP_Query(
			array(
				'meta_key'       => '_llms_order',
				'meta_query'     => array(
					array(
						'key'   => '_llms_parent_course',
						'value' => $this->id,
					),
				),
				'order'          => 'ASC',
				'orderby'        => 'meta_value_num',
				'post_type'      => 'section',
				'posts_per_page' => 500,
			)
		);

		if ( 'ids' === $return ) {
			$r = wp_list_pluck( $q->posts, 'ID' );
		} elseif ( 'posts' === $return ) {
			$r = $q->posts;
		} else {
			$r = array();
			foreach ( $q->posts as $p ) {
				$r[] = new LLMS_Section( $p );
			}
		}

		return $r;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.24.0 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.