LLMS_Post_Handler::create( string $type = 'post', string $title = '', $excerpt = '' )
Create Post
Parameters Parameters
- $type
-
(string) (Optional) [optional: a post type]
Default value: 'post'
- $title
-
(string) (Optional) [optional: a title for the post]
Default value: ''
Return Return
(int) [id of section]
Source Source
File: includes/class.llms.post.handler.php
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | public static function create( $type = 'post' , $title = '' , $excerpt = '' ) { if ( empty ( $title ) ) { $title = 'Section 1' ; } // Create section post. $post_data = apply_filters( 'lifterlms_new_post' , array ( 'post_type' => $type , 'post_title' => $title , 'post_status' => 'publish' , 'post_author' => get_current_user_id(), 'post_excerpt' => $excerpt , ) ); $post_id = wp_insert_post( $post_data , true ); // Check for error in update. if ( is_wp_error( $post_id ) ) { // For now just log the error and set $post_id to 0 (false). llms_log( $post_id ->get_error_message() ); $post_id = 0; } return $post_id ; } |
Expand full source code Collapse full source code View on GitHub