LLMS_Post_Handler::create_section( [int] $course_id, string $title = '' )
Creates a new Section
Description Description
Parameters Parameters
- $course_id
-
([int]) (Required) [the parent course id]
- $title
-
(string) (Optional) [optional: a title for the section]
Default value: ''
Return Return
([int]) [post id of section]
Source Source
File: includes/class.llms.post.handler.php
public static function create_section( $course_id, $title = '' ) { //no course id? no new section! if ( ! isset( $course_id ) ) { return; } //set the section_order variable //get the count of sections in the course and add 1 $course = new LLMS_Course( $course_id ); $sections = $course->get_sections( 'posts' ); $section_order = count( $sections ) + 1; $title = isset( $title ) ? $title : 'New Section'; $post_id = self::create( 'section', $title ); //if post created set parent course and order to order determined above if ( $post_id ) { update_post_meta( $post_id, '_llms_order', $section_order ); $section = new LLMS_Section( $post_id ); $updated_parent_course = $section->set_parent_course( $course_id ); } return $post_id; }
Expand full source code Collapse full source code View on GitHub
User Contributed Notes User Contributed Notes
Permalink: