LLMS_Instructor::get_posts( array $args = array(), string $return = 'llms_posts' )
Retrieve instructor’s posts (courses and memberships, mixed)
Parameters Parameters
- $args
-
(array) (Optional) query arguments passed to WP_Query
Default value: array()
- $return
-
(string) (Optional) return format [llms_posts|ids|posts|query]
Default value: 'llms_posts'
Return Return
(mixed)
Source Source
File: includes/models/model.llms.instructor.php
public function get_posts( $args = array(), $return = 'llms_posts' ) { $serialized_id = serialize( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize array( 'id' => $this->get_id(), ) ); $serialized_id = str_replace( array( 'a:1:{', '}' ), '', $serialized_id ); $args = wp_parse_args( $args, array( 'post_type' => array( 'course', 'llms_membership' ), 'post_status' => 'publish', 'meta_query' => array( array( 'compare' => 'LIKE', 'key' => '_llms_instructors', 'value' => $serialized_id, ), ), ) ); $query = new WP_Query( $args ); if ( 'llms_posts' === $return ) { $ret = array(); foreach ( $query->posts as $post ) { $ret[] = llms_get_post( $post ); } return $ret; } elseif ( 'ids' === $return ) { return wp_list_pluck( $query->posts, 'ID' ); } elseif ( 'posts' === $return ) { return $query->posts; } // If 'query' === $return. return $query; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.13.0 | Introduced. |