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

Get course sections


Description Description


Parameters Parameters

$return

(string) (Optional) type of return [ids|posts|sections]

Default value: 'sections'


Top ↑

Return Return

(array)


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.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: